logoalt Hacker News

e12eyesterday at 2:22 AM3 repliesview on HN

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

antonvsyesterday at 6:08 AM

> 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.

show 1 reply
mortarionyesterday at 10:02 AM

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. ;)

kamaalyesterday at 2:29 AM

If you are planning to write so many if else statements. You might as well write Prolog.