Skip to content

Instantly share code, notes, and snippets.

View diegopacheco's full-sized avatar

Diego Pacheco diegopacheco

View GitHub Profile
@diegopacheco
diegopacheco / map.clj
Created January 10, 2012 01:45
Clojure Map inc
(map inc [1 2 3 4 5 6]) ;;; Result will be (2 3 4 5 6 7)
@diegopacheco
diegopacheco / filter.clj
Created January 10, 2012 01:51
Clojure Filter Map
(filter #(> % 5) (map inc [1 2 3 4 5 6])) ;;; Result will be (6 7)
@diegopacheco
diegopacheco / pojo.clj
Created January 10, 2012 02:04
Clojure Pojo
(defstruct person :name :age :salary) ;;; #'user/person
(def p (struct person "Diego Pacheco" 27 100)) ;;; #'user/p
(prn (:name p)) ;;; "Diego Pacheco" nil
;
; Monads
; ======
;
; * Without monads "pure" functional programming could be very impractical, Hack!
; * You can build environments that support exactly the features that you want
; * Functional able todo IO
; * Function Composition: LINQ, Unix Pipes
; * Good for control tracking of things
; * Encapsulating two things:
@diegopacheco
diegopacheco / fp_concepts_1.md
Created January 15, 2012 18:50
Functional Society - FP Concepts: Higher Order Functions, Currying and Lambda

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

  • Higher Order Functions
  • Lambda
  • Currying

Some useful resources

@diegopacheco
diegopacheco / calc-homework.md
Created January 15, 2012 18:56
Functional Society - Calculator Homework

This gist and a Functional Society Gist to talk about Calculator 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...

Calculator Homework

We need code a simple calculator in Scala and Haskell:

Calculator, basic operations: +, -, /, * (Remember State and Side Effects are not desired)

@diegopacheco
diegopacheco / fizzbuzz-homework.md
Created January 15, 2012 18:59
Functional Society - Fizz Buzz Homework

This gist and a Functional Society Gist to talk about Fizz buzz 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...

Fizz Buzz Homework

Fizz Buzz(French Problem)(Remember State and Side Effects are not desired):

  • Every number that is multiples of 3 - use "fizz"
  • Every number that is multiples of 5 - use "buzz"
  • Every number that is multiples of 3 and 5 - use "fizz buzz"
  • Sample: (1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizz buzz)
@diegopacheco
diegopacheco / 2-meetup-functional-society.md
Created January 15, 2012 19:16
Functional Society #2 meetup 25/02/2012

Meetup 25/02/2012

It's time!!! Let's do another kick ass event at Porto Alegre.

Where?

671, Jari st - Passo da Areia - Porto Alegre | Google Maps Adress => http://g.co/maps/frjub
Ask for "Functional Society" or "Alexandre Poletto"

@diegopacheco
diegopacheco / higher_order_funcs.scala
Created January 17, 2012 21:58
Higher Order Functions in Scala
def payment(f:() => Int):Int = 100 - f()
payment( () => 20 + 10 ) // Result will be 70
@diegopacheco
diegopacheco / higher_order_funcs2.scala
Created January 17, 2012 22:03
Higher Order Functions in Scala
def double( f:() => Int ):() => Int = {
val func = () => f() * 2
return func
}
double( () => 100 )()