Hacker News new | ask | show | jobs
by codery 245 days ago
This looks great, I'm still learning Janet and couldn't write it myself.

I only know about: https://github.com/Engelberg/better-cond in clojure which is different it adds syntax enhancement + control flow convenience.

Similar better-cond can be written in clojure too:

  (defn better-cond [& clauses]
    (fn [& args]
      (some (fn [[pred result]]
              (when (apply pred args)
                (if (fn? result)
                  (apply result args)
                  result)))
            (partition 2 clauses))))
But it's not composable as Janet's version, it will fail when mapped over, because it may return a plain value instead of a callable one. In Janet, all values can naturally participate in higher-order contexts due to its uniform treatment of callables, while in Clojure, only actual functions can be composed or mapped.