Created
December 8, 2025 17:16
-
-
Save fogus/224d658be2a1afaaffe4ac1f25d1fa61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'juxt.core lexicon | |
| ## stack functions | |
| 'dup λ |a -- a a| ; | |
| 'pop λ |a -- | ; | |
| 'dip λ |a q -- (q apply a)| | |
| apply | |
| ; | |
| 'swap λ |a b -- b a| ; | |
| ## functional programming | |
| 'curry λ cons ; | |
| 'compose λ concat ; | |
| 'id λ |a -- a| ; | |
| ## predicates | |
| 'empty? λ dup ->seq nil = ; | |
| 'nothing? λ | |
| (number?) (zero?) (empty?) ifte | |
| ; | |
| 'any? λ true ; | |
| 'small? λ | |
| (number?) | |
| (dup 2 <) | |
| (dup count 2 <) | |
| ifte | |
| ; | |
| 'neg? λ dup 0 < ; | |
| 'pos? λ dup 0 > ; | |
| 'zero? λ dup 0 = ; | |
| 'has? λ swap in? ; | |
| 'falsey? λ truthy? not ; | |
| ## numeric functions | |
| 'dec λ 1 - ; | |
| 'inc λ 1 + ; | |
| ## collection functions | |
| 'ffirst λ first first ; | |
| 'rrest λ rest rest ; | |
| 'head λ 1 take ; | |
| 'swons λ swap cons ; | |
| 'splat λ (id) flat ; | |
| 'reverse λ () swap (swons) flat ; | |
| 'last λ | |
| (rest nothing?) | |
| (first) | |
| (rest last) | |
| ifte | |
| ; | |
| 'max λ |a b -- ((a b >) (a) (b) ifte)| | |
| apply | |
| ; | |
| 'min λ |a b -- ((a b <) (a) (b) ifte)| | |
| apply | |
| ; | |
| ## binding | |
| 'in λ | |
| quotation? not (pop "Bindings must be a quotation of symbols" throw) when | |
| reverse (unit cons reverse meta/me meta/parent meta/parent meta/local true) | |
| map | |
| pop | |
| ; | |
| 'apply2 λ (a b q) in | |
| (b q apply) apply | |
| (a q apply) apply | |
| ; | |
| ## Combinators | |
| 'thrush λ |a b -- b a| | |
| compose | |
| ; | |
| 'Y λ | |
| 'nest λ dup curry ; | |
| (nest) thrush nest apply | |
| ; | |
| ## misc functions -- TODO, reassess | |
| 'lroll λ |(a ...rest) -- (...rest a)| ; | |
| 'rroll λ |(...rest a) -- (a ...rest)| ; | |
| 'rollup λ |a b c -- c a b| ; | |
| ## will not work until non-quotations can appear in rewrites | |
| 'concat λ |(...a) (...b) -- (...a ...b)| ; | |
| ## bad functions to test failure modes | |
| 'fail λ |a b| ; | |
| 'bad-sqr λ [a] in a a * ; | |
| ## should be | |
| ## 'sqr λ (a) in a a * ; 10 sqr ?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment