Skip to content

Instantly share code, notes, and snippets.

View cyberglot's full-sized avatar
👋
good bye

april cyberglot

👋
good bye
View GitHub Profile
@cyberglot
cyberglot / list-plus-one.hs
Created January 1, 2015 18:26
FP in Haskell - Readability II
plus1 :: [Int] -> [Int]
plus1 [] = []
plus1 (x:xs) = x + 1 : plus1 xs
-- plus1 [0,1,2,3]
-- > [1,2,3,4]
@cyberglot
cyberglot / guess.hs
Last active August 29, 2015 14:12
FP in Haskell - Readability
guess :: Int -> [Char]
guess 7 = "Much 7 very wow."
guess x = "Ooops, try again."
-- strongly inspired by http://learnyouahaskell.com
@cyberglot
cyberglot / immutable.ml
Created December 31, 2014 21:50
FP in OCaml - Immutable data
let x = 5;;
x = 6;;
print_int x;; (* prints 5 *)
@cyberglot
cyberglot / high-order-functions2.js
Created December 31, 2014 21:40
FP in JavaScript - High Order Functions
var add = function(a){
return function(b){
return a + b
}
}
var add2 = add(2)
add2(3) // => 5
@cyberglot
cyberglot / high-order-functions1.js
Last active August 29, 2015 14:12
FP in JavaScript - High Order Functions
document.querySelector('#button')
.addEventListener('click', function(){
alert('yay, i got clicked')
})
@cyberglot
cyberglot / first-class-functions.js
Last active August 29, 2015 14:12
FP in JavaScript - First-Class Functions
var add = function(a, b){
return a + b
}