zlacker

[parent] [thread] 10 comments
1. e12e+(OP)[view] [source] 2026-01-20 02:22:21
Oh, wow. I thought the control flow from the readme was a little annoying with the prefix -notation for bigger/smaller than;

    # Control flow
    if (> x 0) {
      (println "positive")
    } else {
      (println "negative or zero")
    }
But that's nothing compared to the scream for a case/switch-statement in the Mandelbrot example...

    # Gradient: " .:-=+*#%@"
        let gradient: string = " .:-=+*#%@"
        let gradient_len: int = 10
        let idx: int = (/ (* iter gradient_len) max_iter)
        if (>= idx gradient_len) {
            return "@"
        } else {
            if (== idx 0) {
                return " "
            } else {
                if (== idx 1) {
                    return "."
                } else {
                    if (== idx 2) {
                        return ":"
                    } else {
                        if (== idx 3) {
                            return "-"
                        } else {
                            if (== idx 4) {
                                return "="
                            } else {
                                if (== idx 5) {
                                    return "+"
                                } else {
                                    if (== idx 6) {
                                        return "*"
                                    } else {
                                        if (== idx 7) {
                                            return "#"
                                        } else {
                                            if (== idx 8) {
                                                return "%"
                                            } else {
                                                return "@"
                                            }
                                        }
replies(3): >>kamaal+K >>antonv+ol >>mortar+LL
2. kamaal+K[view] [source] 2026-01-20 02:29:02
>>e12e+(OP)
If you are planning to write so many if else statements. You might as well write Prolog.
3. antonv+ol[view] [source] 2026-01-20 06:08:43
>>e12e+(OP)
> scream for a case/switch-statement

Maybe I’m missing some context, but all that actually should be needed in the top-level else block is ‘gradient[idx]’. Pretty much anything else is going to be longer, harder to read, and less efficient.

replies(1): >>e12e+Zy
◧◩
4. e12e+Zy[view] [source] [discussion] 2026-01-20 08:30:53
>>antonv+ol
True, with early return - there's no need to actually nest with else.

Logically this still would be a case/switch though...

replies(1): >>vidarh+TG
◧◩◪
5. vidarh+TG[view] [source] [discussion] 2026-01-20 09:30:01
>>e12e+Zy
The point was that logically it would be an array lookup by index.

There's no need for any conditional construct here whatsoever.

You'll note it has already constructed a string in the right order to do that, but then copped out with the if-else.

replies(1): >>e12e+s71
6. mortar+LL[view] [source] 2026-01-20 10:02:41
>>e12e+(OP)
I mean for all intents and purposes this language is designed for use by LLM's, not humans, and the AI probably won't complain that a switch-case statement is missing. ;)
◧◩◪◨
7. e12e+s71[view] [source] [discussion] 2026-01-20 13:09:06
>>vidarh+TG
True enough. On that note, I had a look at the language reference - there's arrays - but also this:

    (char_at s index)        # Get ASCII value at index (0-based)
    (string_from_char code)  # Create string from ASCII value
So, you can pluck a character... From an UTF-8 string? What if the rendering used multibyte characters?
replies(1): >>vidarh+PV1
◧◩◪◨⬒
8. vidarh+PV1[view] [source] [discussion] 2026-01-20 17:14:08
>>e12e+s71
Well, we can see the string, and we can see that is uses plain ASCII.
replies(1): >>e12e+8Z1
◧◩◪◨⬒⬓
9. e12e+8Z1[view] [source] [discussion] 2026-01-20 17:24:42
>>vidarh+PV1
In this case, sure. But what if we shifted to rendering with emojis or whatnot. What would the first ASCII character of the string be?
replies(1): >>vidarh+AZ4
◧◩◪◨⬒⬓⬔
10. vidarh+AZ4[view] [source] [discussion] 2026-01-21 14:40:03
>>e12e+8Z1
If you anticipate that need, you just store the gradient as an array of strings, and you still then only need a trivial lookup.
replies(1): >>e12e+d07
◧◩◪◨⬒⬓⬔⧯
11. e12e+d07[view] [source] [discussion] 2026-01-22 01:30:57
>>vidarh+AZ4
I was more commenting on the language design here; the idea of indexing into a UTF-8 string and returning an ASCII character. What does the index count? Bytes? There doesn't seem to be a way to get UTF-8 characters from strings?

Ed: There seems to be an UTF-8 library:

https://github.com/jordanhubbard/nanolang/tree/main/modules/...

[go to top]