Last active
August 24, 2024 20:11
-
-
Save lukechampine/1b68178af5e05b30fb8e9efe96316514 to your computer and use it in GitHub Desktop.
Evolution of a Hoon Programmer
This file contains 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
:: Hoonlet | |
:: | |
|= n=@ | |
?: =(n 0) | |
1 | |
(mul n $(n (dec n))) | |
:: | |
:: Commie Hoontard | |
:: (...daydreaming of his very own Type 59...) | |
:: | |
|= n=@ | |
(roll (gulf 1 n) mul) | |
:: | |
:: Nazi Hoontard | |
:: (...hook, line, and sinker...) | |
:: | |
|= n=@ | |
(reel (gulf 1 n) mul) | |
:: | |
:: Accumulating Hoontard | |
:: (...former Haskell programmer...) | |
:: | |
|= n=@ | |
=- (go n 1) | |
^= go | |
|= [n=@ acc=@] | |
?- n | |
~ acc | |
@ (. (dec n) (mul acc n)) | |
== | |
:: | |
:: Iterative Hoontard | |
:: (...lost without his lööps; prefers "mutating" the subject...) | |
:: | |
|= n=@ | |
=< (for init done next) | |
|% | |
++ for | |
|= [i=[@ @] d=$-(@ ?) n=$-([@ @] [@ @])] | |
?: (d -.i) | |
+.i | |
=. i (n i) | |
$ | |
++ init | |
[0 1] | |
++ done | |
|= i=@ | |
=(i n) | |
++ next | |
|= [i=@ m=@] | |
=. i +(i) | |
=. m (mul m i) | |
[i m] | |
-- | |
:: | |
:: Tacit Hoontard | |
:: (...sneers in your face, spreading his wide wings...) | |
:: | |
|=(@ ?:(=(+< *@) +(*_+<) (mul +< $(+< (dec +<))))) | |
:: | |
:: Pointless Hoontard | |
:: (...beyond the gateless gate...) | |
:: | |
(cork (cury gulf 1) (cury (curr (fold @ @) mul) 1)) | |
:: | |
:: Obscurantist Hoontard | |
:: (...a real ass; needs more fiber in his diet...) | |
:: | |
!. |* n=_0 => |. %- | |
flop %+ spun %- gulf | |
[.(- =(+ -))]:`n |: ;; | |
[@ @] !=(...) =< .^. | |
(mul &2) :(mule ,:-:$) | |
:: | |
:: Continuation-passing Hoontard | |
:: (...kicked out of culinary school; always plotting some new scheme...) | |
:: | |
|= n=@ | |
%. [(bake same @) n] | |
|= [f=$-(@ @) n=@] | |
?: =(n 0) (f 1) | |
%= $ | |
f (bake (cork f (cury mul n)) @) | |
n (dec n) | |
== | |
:: | |
:: Church-going Hoontard | |
:: (...a real fixer-upper...) | |
:: | |
|^ (y fac) | |
++ y | |
|= f=$-($-(@ @) $-(@ @)) | |
|= x=@ | |
((f .) x) | |
++ fac | |
|= f=$-(@ @) | |
|= x=@ | |
?: =(x 0) 1 | |
(mul x (f (dec x))) | |
-- | |
:: | |
:: Sugar-free Hoontard | |
:: (...former Assembly programmer; big Rothko fan...) | |
:: | |
:- ^= n 0 . |% ++ $ | |
?: .= n 0 .+ 0 => :- | |
^= r %= $ n => :- dec | |
. => %= - +< n == $ | |
== . => :- mul . => %= | |
- +< :- n r == $ -- | |
:: | |
:: Nockchad | |
:: (...if you wish to compute factorial from scratch, | |
:: you must first invent the universe...) | |
:: | |
=> ~ :: look ma, no subject! | |
|^ fac | |
++ dec | |
|= a=@ | |
=| b=@ | |
|- | |
?: =(a +(b)) b | |
$(b +(b)) | |
++ add | |
|= [a=@ b=@] | |
?: =(0 a) b | |
$(a (dec a), b +(b)) | |
++ mul | |
|= [a=@ b=@] | |
=| c=@ | |
|- | |
?: =(0 a) c | |
$(a (dec a), c (add b c)) | |
++ fac | |
|= n=@ | |
?: =(n 1) 1 | |
(mul n $(n (dec n))) | |
-- | |
:: | |
:: Unary Nockchad | |
:: (...Martian education tends to liberate one from petty concerns, | |
:: e.g. the efficiency of hardware-based integers...) | |
:: | |
=> ~ | |
|^ | |
|= n=@ | |
(decel (fac (incel n))) | |
++ inc |=(* `+6) | |
++ dec |=(^ +13) | |
++ add | |
|= [xs=* ys=*] | |
?@ xs ys | |
$(xs (dec xs), ys (inc ys)) | |
++ mul | |
|= [xs=* ys=*] | |
=| zs=* | |
|- | |
?@ xs zs | |
$(xs (dec xs), zs (add ys zs)) | |
++ fac | |
|= l=* | |
?@ l (inc l) | |
(mul l (fac (dec l))) | |
++ incel | |
|= n=@ | |
=| i=@ | |
|- | |
?: =(n i) ~ | |
(inc $(i +(i))) | |
++ decel | |
|= n=* | |
=| i=* | |
|- | |
?: =(n i) 0 | |
+($(i (inc i))) | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment