Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
(ns irepl)
(defn inspect [val]
(println "adding inspect message " {:op :inspect :val val})
val)
(defn- irepl-eval [form]
(clojure.core/eval
`(let [~'inspect ~inspect]
~form)))
@fogus
fogus / cont.clj
Created June 28, 2022 16:00 — forked from hiredman/cont.clj
(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)))

Quirky computing books of the day

<2022-06-21 Tue>

Functional Programming and Its Applications by Darlington, Henderson, and Turner

TWEET:

/**
* 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));
}
@fogus
fogus / cdart.md
Last active April 22, 2022 16:26

RESOLUTION

I had an older version of Dart installed in a Flutter dev setup and it seemed that it was being picked up at some point in the init/build process. Removing the old Dart version fixed the errors below.

versions:

OSX

java -version
openjdk version "11.0.8" 2020-07-14
@fogus
fogus / chain.st
Created March 30, 2022 16:39 — forked from zeroflag/chain.st
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
@fogus
fogus / monad.bas
Created February 11, 2022 17:44
Sid Sackson's Monad game in QBasic
DECLARE SUB Hugemonad ()
DECLARE SUB Colours ()
SCREEN 9
CLEAR , , 5000
WIDTH , 43
CALL Colours
CALL Hugemonad
LINE (380, 240)-(596, 303), 2, BF