Functional Programming and Its Applications by Darlington, Henderson, and Turner
TWEET:
(defmacro return% [a] | |
`(fn return-fn# [success# error#] | |
#(try | |
(success# ~a) | |
(catch Throwable t# | |
(error# t#))))) | |
(defn bind% [m b] | |
(fn a [success error] | |
#(m (fn x [value] ((b value) success error)) error))) |
/** | |
* An interned mapping is one where a var's ns matches the current ns and its sym matches the mapping key. | |
* Once established, interned mappings should never change. | |
*/ | |
private boolean isInternedMapping(Symbol sym, Object o){ | |
return(o instanceof Var && | |
((Var) o).ns == this && | |
((Var) o).sym.equals(sym)); | |
} |
Object>>chain | |
^ ChainProxy new setTarget: self | |
ChainProxy>>doesNotUnderstand: aMessage | |
target := aMessage sendTo: target. | |
^ target | |
ChainProxy>>setTarget: anObject | |
target := anObject. | |
^ self |
;;;; 0 - naive | |
(defn take+rest0 [n coll] | |
[(->> coll (take n) vec) | |
(drop n coll)]) | |
; "Elapsed time: 700 msecs" with (range), take 10 | |
; "Elapsed time: 5860 msecs" with (range), take 100 | |
; "Elapsed time: 818 msecs" with [0...99999], take 10 | |
; "Elapsed time: 6439 msecs" with [0...99999], take 100 |
Boardgame you... | |
don’t like: cards against humanity | |
think is overhyped: munchkin | |
think is underappreciated: blockers, klunker, hyle | |
love: go, gin, homeworlds | |
can play over and over: hearts | |
should play more often: tramways, fjords | |
Got me into hobby: civilization | |
changed my life: chess | |
surprised me the most: the mushroom eaters |
;; qualified method expansions from `make-fn` | |
;; https://github.com/fogus/thneed/blob/master/src/fogus/rdr.clj | |
;; METHOD: Math/abs | |
;; SIGS: [[int] [long] [float] [double]] | |
(clojure.core/fn abs11949 | |
([G__11950] | |
(clojure.core/cond |
DECLARE SUB Hugemonad () | |
DECLARE SUB Colours () | |
SCREEN 9 | |
CLEAR , , 5000 | |
WIDTH , 43 | |
CALL Colours | |
CALL Hugemonad | |
LINE (380, 240)-(596, 303), 2, BF |
import random | |
class Die: | |
def __init__(self, n): | |
self.sides = n | |
def roll(self): | |
return random.randint(1, self.sides) | |
dice = [Die(6), Die(6), Die(6)] |