Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.37 KB | None | 0 0
  1. Death-Lair-of-Killer-Bambi:ruby stickycake$ irb
  2. cannot load such file -- irb/autocompletion
  3. 1.9.3-p194 :001 > myAlexShapiro = ->(x){ ->(y){ x + y } }
  4.  => #<Proc:0x007fb80d005218@(irb):1 (lambda)>
  5. 1.9.3-p194 :002 > myAlexShapiro"
  6. 1.9.3-p194 :003"> ^C
  7. 1.9.3-p194 :003 > myAlexShapiro[3]
  8.  => #<Proc:0x007fb80d022d68@(irb):1 (lambda)>
  9. 1.9.3-p194 :004 > myAlexShapiro[3][4]
  10.  => 7
  11. 1.9.3-p194 :005 > myAlexShapiro.curry
  12.  => #<Proc:0x007fb80c826768 (lambda)>
  13. 1.9.3-p194 :006 > myAlexShapiro.curry[3][4]
  14.  => 7
  15. 1.9.3-p194 :007 > myAlexShapiro = ->(x,y){ x + y  }
  16.  => #<Proc:0x007fb80c8491c8@(irb):7 (lambda)>
  17. 1.9.3-p194 :008 > myAlexShapiro.arity
  18.  => 2
  19. 1.9.3-p194 :009 > myAlexShapiro.curry
  20.  => #<Proc:0x007fb80c867ec0 (lambda)>
  21. 1.9.3-p194 :010 > myAlexShapiro.curry.arity
  22.  => -1
  23. 1.9.3-p194 :011 > myAlexShapiro.curry[3,4]
  24.  => 7
  25. 1.9.3-p194 :012 > sumDahlia = ->(a, b){ a + b }
  26.  => #<Proc:0x007fb80c880ad8@(irb):12 (lambda)>
  27. 1.9.3-p194 :013 > addTwo = sumDahlia.curry"
  28. 1.9.3-p194 :014"> ^C
  29. 1.9.3-p194 :014 > addTwo = sumDahlia.curry[2]
  30.  => #<Proc:0x007fb80c896db0 (lambda)>
  31. 1.9.3-p194 :015 > addTwo[3]
  32.  => 5
  33. 1.9.3-p194 :016 > sumDahlia = ->(a, b){ a - b }
  34.  => #<Proc:0x007fb80c8a5d60@(irb):16 (lambda)>
  35. 1.9.3-p194 :017 > addTwo = sumDahlia.curry[2]
  36.  => #<Proc:0x007fb80c8a2908 (lambda)>
  37. 1.9.3-p194 :018 > addTwo[3]
  38.  => -1
  39. 1.9.3-p194 :019 > discriminateUser = ->(criterion, user){ user.is_a?(criterion)}
  40.  => #<Proc:0x007fb80c88d3f0@(irb):19 (lambda)>
  41. 1.9.3-p194 :020 > isIdiot = discriminateUser.curry(Idiot)
  42. NameError: uninitialized constant Idiot
  43.     from (irb):20
  44.     from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
  45. 1.9.3-p194 :021 > Idiot = Strig
  46. NameError: uninitialized constant Strig
  47.     from (irb):21
  48.     from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
  49. 1.9.3-p194 :022 > Idiot = Strimg
  50. NameError: uninitialized constant Strimg
  51.     from (irb):22
  52.     from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
  53. 1.9.3-p194 :023 > Idiot = String
  54.  => String
  55. 1.9.3-p194 :024 > isIdiot = discriminateUser.curry(Idiot)
  56. TypeError: can't convert Class into Integer
  57.     from (irb):24:in `curry'
  58.     from (irb):24
  59.     from /Users/stickycake/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
  60. 1.9.3-p194 :025 > isIdiot = discriminateUser.curry[Idiot]
  61. => #<Proc:0x007fb80c850c98 (lambda)>
  62. 1.9.3-p194 :026 > isIdiot["Jeremy"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement