Skip to content

Instantly share code, notes, and snippets.

View argumatronic's full-sized avatar
🏠
Working from home

Julie Moronuki argumatronic

🏠
Working from home
View GitHub Profile
@Gabriella439
Gabriella439 / fibonacci.hs
Created March 25, 2018 00:52
Efficient fibonacci numbers using infinite precision integer arithmetic
import Numeric.Natural (Natural)
import qualified Data.Semigroup
-- | @fibonacci n@ computes the @nth@ fibonacci number efficiently using infinite
-- precision integer arithmetic
--
-- Try @fibonacci 1000000@
fibonacci :: Natural -> Natural
fibonacci n = x01 (Data.Semigroup.mtimesDefault n m)
{-# LANGUAGE DeriveFunctor #-}
import Control.Arrow ((&&&))
import Data.Bifunctor
-- Recursion Schemes for Dynamic Programming
-- Kabanov and Vene, Mathematics for Program Construction 2006
-- Basic stuff
newtype Mu f = In { out :: f (Mu f) }
@beesandbombs
beesandbombs / dancinDots.pde
Created April 5, 2018 19:26
dancin’ dots
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@marcosh
marcosh / Application.hs
Created June 14, 2018 13:20
Web applications as profunctors
module Application where
import Data.Profunctor
newtype Application request response = Application {unApplication :: request -> IO response}
instance Profunctor Application where
dimap actOnRequest actOnResponse application = Application $ (fmap actOnResponse) . (unApplication application) . actOnRequest

Writing a paper, according to SPJ

Source: https://www.cis.upenn.edu/~sweirich/icfp-plmw15/slides/peyton-jones.pdf

  1. Abstract (4 sentences, write last; used by program committee members to decide which papers to read)
    1. State the problem
    2. Say why it’s an interesting problem
    3. Say what your solution achieves
    4. Say what follows from your solution
  2. Introduction (1 page)
@bradparker
bradparker / Main.hs
Last active November 21, 2018 22:10
Essence of the iterator pattern word count
module Main where
import Data.Bool (bool)
import Control.Monad ((<=<))
import Control.Monad.State (State, evalState, get, put)
import Data.Char (isSpace)
import Data.Foldable (traverse_)
import Data.Functor.Compose (Compose(Compose, getCompose))
import Data.Functor.Const (Const(Const, getConst))
import Data.Functor.Product (Product(Pair))
@jaspervdj
jaspervdj / list-vs-non-empty.hs
Created April 3, 2019 07:37
Is List or NonEmpty "simpler"? Neither.
--------------------------------------------------------------------------------
-- Is List or NonEmpty "simpler"? Neither:
type NonEmpty a = Fix (Compose ((,) a) Maybe)
type List a = Fix (Compose Maybe ((,) a))
--------------------------------------------------------------------------------
newtype Fix f = Fix {unFix :: f (Fix f)}
@friedbrice
friedbrice / lenses-introduction.js
Last active April 4, 2024 16:02
Javascript has lenses?
var danielsLensTalk = {
recordId: 0,
creation: {
user: '[email protected]',
moment: {
date: {
year: 2019,
month: 5,
day: 29
},