zlacker

[parent] [thread] 6 comments
1. e12e+(OP)[view] [source] 2026-01-20 08:30:53
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+U7
2. vidarh+U7[view] [source] 2026-01-20 09:30:01
>>e12e+(OP)
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+ty
◧◩
3. e12e+ty[view] [source] [discussion] 2026-01-20 13:09:06
>>vidarh+U7
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+Qm1
◧◩◪
4. vidarh+Qm1[view] [source] [discussion] 2026-01-20 17:14:08
>>e12e+ty
Well, we can see the string, and we can see that is uses plain ASCII.
replies(1): >>e12e+9q1
◧◩◪◨
5. e12e+9q1[view] [source] [discussion] 2026-01-20 17:24:42
>>vidarh+Qm1
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+Bq4
◧◩◪◨⬒
6. vidarh+Bq4[view] [source] [discussion] 2026-01-21 14:40:03
>>e12e+9q1
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+er6
◧◩◪◨⬒⬓
7. e12e+er6[view] [source] [discussion] 2026-01-22 01:30:57
>>vidarh+Bq4
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]