I hereby claim:
- I am twopoint718 on github.
- I am cjw (https://keybase.io/cjw) on keybase.
- I have a public key whose fingerprint is 1AE3 0A0B 22CC FC2D 3AA7 A85E C40B DE79 6D77 35C5
To claim this, I am signing this object:
| module Reader | |
| def [](state) | |
| @state = state | |
| end | |
| def with_state | |
| yield(@state) | |
| end | |
| end |
| > {-# LANGUAGE TemplateHaskell #-} | |
| > module Main where | |
| > import Control.Lens | |
| I think a big reason why I'm so stoked about this is that it's a solid library | |
| that's offering a lens-based API (something that I think will show up more and | |
| more as time goes on). I'm still digging into them, but lenses are sort of | |
| like the "." (dot) from Ruby, but implemented as a library and infinitely more | |
| flexible: |
| def average_transaction_amount(user) | |
| purchases = user.purchases | |
| total = purchases.map(&:amount).inject(&:+) | |
| total / purchases.count | |
| end | |
| def parameterized_average_transaction_amount(user, purchase_acc, amount_acc) | |
| purchases = purchase_acc.call(user) | |
| total = purchases.map(&amount_acc).inject(&:+) | |
| total / purchases.count |
| require 'minitest/autorun' | |
| # type decls. --------------------------------------------------------- | |
| class Person | |
| attr_reader :first, :last | |
| def initialize(f, l) | |
| @first = f | |
| @last = l |
| -- split :: [t] -> ([t], [t]) | |
| split [] = ([], []) | |
| split [h] = ([h], []) | |
| split (x:y:t) = let (s1, s2) = split t | |
| in (x:s1, y:s2) | |
| -- merge :: Ord a => ([a], [a]) -> [a] | |
| merge ([], x) = x | |
| merge (x, []) = x | |
| merge (h1:t1, h2:t2) = |
| {-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-} | |
| newtype TimeUnit = TimeUnit Integer | |
| deriving (Eq, Show, Num) | |
| instance Num (TimeUnit -> TimeUnit) where | |
| fromInteger n = \(TimeUnit scale) -> TimeUnit (n * scale) | |
| seconds, minutes, hours, days :: TimeUnit |
| #!/bin/sh | |
| ############################################################################### | |
| # | |
| # COMPUTE YOUR TRUE GIT POWER. CHALLENGE YOUR FRIENDS. ...THEY'LL SOON BE YOUR | |
| # FORMER FRIENDS WHEN YOU HAVE MORE GITPOWER. SHUTUP, THEM! YOU DON'T NEED | |
| # THOSE LOSERS PLACE REAL-MONEY BETS. GET SUPER RICH. TELL YOUR BOSS YOU'RE | |
| # BETTING ON GIT! THEY'LL BE ALL LIKE "OKAY, THAT'S COOL" | |
| # | |
| ############################################################################### |
| module Main where | |
| import Data.List (sort, intersperse, intercalate) | |
| scrambled :: [(Int, String)] | |
| scrambled = [(26,"as"), (20,"because"), (2,"cannot"), (24,"details"), | |
| (29,"does"), (1,"i"), (23,"idle"), (7,"in"), (21,"it"), (25,"just"), | |
| (28,"memory"), (12,"night"), (17,"night"), (10,"of"), (27,"our"), | |
| (18,"pleases"), (9,"solitude"), (6,"suburbs"), (22,"suppresses"), | |
| (15,"that"), (5,"the"), (8,"the"), (11,"the"), (16,"the"), |
| class Point | |
| private_class_method :new | |
| attr_reader :x, :y, :z | |
| def self.build | |
| ->(x, y, z){ new(x, y, z).freeze }.curry | |
| end | |
| def initialize(x, y, z) | |
| @x, @y, @z = x, y, z |
I hereby claim:
To claim this, I am signing this object: