Skip to content

Instantly share code, notes, and snippets.

View diegopacheco's full-sized avatar

Diego Pacheco diegopacheco

View GitHub Profile
@diegopacheco
diegopacheco / languages-bands.md
Created February 20, 2012 06:19
Language as Bands

By joe programmer, Thursday 18 June 2009 03:08

  • Perl/Python/Ruby = Britney Spears, Lindsay Lohan (total trash, throw away languages for throw away programs, bitrot accelerated)
  • Java = Spice Girls, New Kids on the Block (marketing driven drivel)
  • C/C++ = Tool, Metallica (causing of much angst, though not so bad for it's purpose)
  • Asm = Rap (potentially interesting, but lacking dimensions)
  • Prolog = Beethoven
  • SmallTalk = Mozart
  • Lisp = Bach
@diegopacheco
diegopacheco / 3fp2.md
Created February 26, 2012 16:40
3 FP Concepts: Recursion, List Comprehensions and Monads

This gist and a Functional Society Gist to talk about FP concepts, so people can share links and help each other to get the concepts right and make questions, get you question answered and so on and on...

3 FP Concepts

  • Recursion
  • List Comprehensions
  • Monads

Some useful resources

@diegopacheco
diegopacheco / fs-bank.md
Created February 26, 2012 16:42
Functional Society - Bank Homework

This gist and a Functional Society Gist to talk about Bank homework, so people can share links and help each other to get the homework right and make questions, get you question answered and so on and on...

Bank Homework

We need code a simple bank management system in Scala and Haskell:
Simple account management operations like: (Remember State and Side Effects are not desired)

Operations

  • deposit
@diegopacheco
diegopacheco / fs-contact.md
Created February 26, 2012 16:46
Functional Society - Contact Address Homework

This gist and a Functional Society Gist to talk about Contact Address Homework, so people can share links and help each other to get the homework right and make questions, get you question answered and so on and on...

Contact Address Homework

Contact Address Homework (Remember State and Side Effects are not desired):

  • We need the following features:
    • Add contacts(name, email and phone)
    • Remove contacts
  • Search contacts
@diegopacheco
diegopacheco / scala-simple-rec.scala
Created March 6, 2012 04:19
Scala Simple Recursion
def factorial(number:Int) : Int = if (number == 1) return 1 else number * factorial (number - 1)
println(factorial(5))
@diegopacheco
diegopacheco / reca-tail.scala
Created March 6, 2012 04:23
Scala Recursion Tail Recursive
def factorial(accumulator: Int, number: Int) : Int = {
if(number == 1) return accumulator
factorial(number * accumulator, number - 1) // Last thing you do you call a function.. will be tail recursive!
}
println(factorial(1,5))
@diegopacheco
diegopacheco / scala-rec-fun.scala
Created March 6, 2012 04:26
Scala Recursion 2 funcs
def factorial(number: Int) : Int = {
def factorialWithAccumulator(accumulator: Int, number: Int) : Int = {
if (number == 1) return accumulator
else factorialWithAccumulator(accumulator * number, number - 1)
}
factorialWithAccumulator(1, number)
}
println(factorial(5))
@diegopacheco
diegopacheco / fac.hs
Created March 6, 2012 04:34
Haskell Factorial Recursion
factorial :: Num a => a -> a
factorial 0 = 1
factorial n = n * factorial (n-1)
@diegopacheco
diegopacheco / prod.hs
Created March 6, 2012 04:39
Haskell Product Recursion/Factorial Killer
factorial2 :: (Num a, Enum a) => a -> a
factorial2 n = product [1..n]
@diegopacheco
diegopacheco / lc.hs
Created March 6, 2012 04:56
Haskell List Compreenshions
take 10 [ (i,j) | i <- [1,2], j <- [1..]] -- [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)]
[x*2 | x <- [1..10]] -- [2,4,6,8,10,12,14,16,18,20]