3 ms·
Sure. I’ve done it for Bel. (def no (x) (id x nil)) (def atom (x) (no (id (type x) ‘pair))) (def some (x f) (if (no x) nil (f (car
by sillysaurusx 4y ago
Sure. I’ve done it for Bel.
(def no (x)
(id x nil))
(def atom (x)
(no (id (type x) ‘pair)))
(def some (x f)
(if (no x) nil
(f (car x)) x
(some (cdr x))))
(def all (x)
(if (no x) t
(f (car x)) (all (cdr x))
nil)))
I don’t even have to pull up bel.bel to know that those are almost perfect replicas. I typed it on my iPad.
EDIT: as far as I can tell, the only diff is that all comes before some. https://sep.yimg.com/ty/cdn/paulgraham/bel.bel?t=1595850613& https://sep.yimg.com/ty/cdn/paulgraham/bel.bel?t=1595850613&
I could have kept going through most of the implementation.
- falcolas 4y agoI'd wager that most folks would consider the code for some basic list operations to be a little different from outputting a complete specific implementation of a fast square root function with its exact constants, including the comments.
- sillysaurusx 4y agoWhy? They’re both basic functions. I’d argue that if pg had left comments and constants, I’d have replicated those too. Perhaps my example isn’t as impressive as the model’s capability, but operationally it’s the same.