Skip to content

Instantly share code, notes, and snippets.

@zobar
zobar / .gitignore
Last active December 30, 2015 16:59
Chip: composable vector operations in Ruby.
/.yardoc
/.yardopts
/coverage
/doc
@zobar
zobar / look_and_say.clj
Last active August 29, 2015 13:57
Look and say, ruby & clojure
(ns look-and-say)
(defn- consecutive [string]
(map first (re-seq #"(.)\1*" string)))
(defn- say [chars]
[(count chars) (first chars)])
(defn- get-next [string]
(apply str (mapcat say (consecutive string))))
@zobar
zobar / .gitignore
Last active August 29, 2015 14:04
Ruby simulation of a full adder
.rbenv-gemsets
.yardopts
*/
@zobar
zobar / gist:9ad4c0dab8abdbc3ba35
Last active June 3, 2016 02:55
weird movie nite
contrived value input =
let parsed = read input in -- parsed implements Read
-- read takes a String, therefore input must be String
if parsed == value -- parsed & value are same type, which implements Eq
then Just parsed
else Nothing
{-
If type bindings are still ambiguous after the function is defined, it's
preferred to leave them unresolved rather than forcing them. This keeps your
$ ghci
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> show
<interactive>:2:1:
No instance for (Show (a0 -> String)) arising from a use of ‘print’
In a stmt of an interactive GHCi command: print it
@zobar
zobar / postage.rates
Last active August 29, 2015 14:13
Sample program from Applesoft BASIC Programmer's Reference Manual
10 REM POSTAGE RATES
20 :
30 REM DETERMINES POSTAGE FEES
40 REM FOR EXPRESS, FIRST CLASS,
50 REM AND PRIORITY MAIL
60 REM V29/01/82
70 REM BY JOHN SCRIBBLEMONGER
100 REM MENU OF POSTAGE CLASSES
110 HOME
Within an easy walk of the hotel:
1. Just south of you is Millennium Park
<http://www.cityofchicago.org/city/en/depts/dca/supp_info/millennium_park_-artarchitecture.html>.
Worth going to. You have to go and take a picture of yourself reflected in the
Bean
<http://www.cityofchicago.org/content/dam/city/depts/dca/Millennium%20Park/cloudgate800.jpg>.
And you can admire the Pritzker Pavilion. Probably not the Buckingham
Fountain in March, though... But maybe the "fountain
<http://www.cityofchicago.org/content/dam/city/depts/dca/Millennium%20Park/crownfountain800.jpg>"
@zobar
zobar / encapsulation.clj
Created July 27, 2015 16:43
Encapsulation without objects
(ns functor
(:refer-clojure :exclude [map]))
(defprotocol Functor
"Defines functor/Functor"
(map [functor f]))
(defn each
[functor f]
(map functor f)
Sleep:
I know this -> Welcome Apartments: Welcome.is (This is where we stayed both
times in the city center)
People I talked to stayed here -> City Center Hotel (very popular)
I've all the monies in the world -> Hotel Borg
Swim or Soak:
Laugardalslaug Geothermal Pools (Locals in the 101 swim here)
Blue Lagoon (Beautiful but requires like a good half-day: it's 45 minutes from
Reykjavik, takes 20 minutes to get in, and at least an in the water hour to