Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Death-Lair-of-Killer-Bambi:ruby stickycake$ irb
- cannot load such file -- irb/autocompletion
- 1.9.3-p194 :001 > myAlexShapiro = ->(x){ ->(y){ x + y } }
- => #<Proc:0x007fb80d005218@(irb):1 (lambda)>
- 1.9.3-p194 :002 > myAlexShapiro"
- 1.9.3-p194 :003"> ^C
- 1.9.3-p194 :003 > myAlexShapiro[3]
- => #<Proc:0x007fb80d022d68@(irb):1 (lambda)>
- 1.9.3-p194 :004 > myAlexShapiro[3][4]
- => 7
- 1.9.3-p194 :005 > myAlexShapiro.curry
- => #<Proc:0x007fb80c826768 (lambda)>
- 1.9.3-p194 :006 > myAlexShapiro.curry[3][4]
- => 7
- 1.9.3-p194 :007 > myAlexShapiro = ->(x,y){ x + y }
- => #<Proc:0x007fb80c8491c8@(irb):7 (lambda)>
- 1.9.3-p194 :008 > myAlexShapiro.arity
- => 2
- 1.9.3-p194 :009 > myAlexShapiro.curry
- => #<Proc:0x007fb80c867ec0 (lambda)>
- 1.9.3-p194 :010 > myAlexShapiro.curry.arity
- => -1
- 1.9.3-p194 :011 > myAlexShapiro.curry[3,4]
- => 7
- 1.9.3-p194 :012 > sumDahlia = ->(a, b){ a + b }
- => #<Proc:0x007fb80c880ad8@(irb):12 (lambda)>
- 1.9.3-p194 :013 > addTwo = sumDahlia.curry"
- 1.9.3-p194 :014"> ^C
- 1.9.3-p194 :014 > addTwo = sumDahlia.curry[2]
- => #<Proc:0x007fb80c896db0 (lambda)>
- 1.9.3-p194 :015 > addTwo[3]
- => 5
- 1.9.3-p194 :016 > sumDahlia = ->(a, b){ a - b }
- => #<Proc:0x007fb80c8a5d60@(irb):16 (lambda)>
- 1.9.3-p194 :017 > addTwo = sumDahlia.curry[2]
- => #<Proc:0x007fb80c8a2908 (lambda)>
- 1.9.3-p194 :018 > addTwo[3]
- => -1
- 1.9.3-p194 :019 > discriminateUser = ->(criterion, user){ user.is_a?(criterion)}
- => #<Proc:0x007fb80c88d3f0@(irb):19 (lambda)>
- 1.9.3-p194 :020 > isIdiot = discriminateUser.curry(Idiot)
- NameError: uninitialized constant Idiot
- from (irb):20
- from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
- 1.9.3-p194 :021 > Idiot = Strig
- NameError: uninitialized constant Strig
- from (irb):21
- from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
- 1.9.3-p194 :022 > Idiot = Strimg
- NameError: uninitialized constant Strimg
- from (irb):22
- from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
- 1.9.3-p194 :023 > Idiot = String
- => String
- 1.9.3-p194 :024 > isIdiot = discriminateUser.curry(Idiot)
- TypeError: can't convert Class into Integer
- from (irb):24:in `curry'
- from (irb):24
- from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
- 1.9.3-p194 :025 > isIdiot = discriminateUser.curry[Idiot]
- => #<Proc:0x007fb80c850c98 (lambda)>
- 1.9.3-p194 :026 > isIdiot["Jeremy"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement