Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Created December 14, 2014 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravinggenius/13a3e3f4e10cd98daa0d to your computer and use it in GitHub Desktop.
Save ravinggenius/13a3e3f4e10cd98daa0d to your computer and use it in GitHub Desktop.
[1] module > foo = -> (a, b, c) { a + b + c }
=> {
-> (a<#< System.Object >>, b<#< System.Object >>, c<#< System.Object >>) { ... }
}
[2] module > foo4 = foo(4)
=> {
-> (b<#< System.Object >>, c<#< System.Object >>) { ... }
}
[3] module > foo4_5 = foo4(5)
=> {
-> (c<#< System.Object >>) { ... }
}
[4] module > foo(1, 2, 3)
6
[5] module > foo4(5, 6)
15
[6] module > foo4_5(70)
79
[7] module > foo4(5)(6)
15
[8] module > foo(1)(2)(3)
6
[9] module > bar = -> (a, b, c = 3) { a + b + c }
=> {
-> (a<#< System.Object >>, b<#< System.Object >>) { ... }
-> (a<#< System.Object >>, b<#< System.Object >>, c<#< System.Object >>) { ... }
}
[10] module > bar(1, 2, 3)
6
[11] module > bar(1, 5)
9
[12] module > bar2 = bar(2)
=> {
-> (b<#< System.Object >>) { ... }
-> (b<#< System.Object >>, c<#< System.Object >>) { ... }
}
[13] module > bar(1, 2)
6
[14] module > bar2(4)
#<Rip::Exceptions::NativeException (#10) "Unknown exception has occurred. Please open an issue report at github.com/rip-lang/rip/issues" @ >
Call stack (native):
#<RuntimeError: cannot find overload for arguments given>
/Users/thomas/Code/rip-rip/lib/rip/core/lambda.rb:144:in `apply'
/Users/thomas/Code/rip-rip/lib/rip/core/lambda.rb:57:in `call'
/Users/thomas/Code/rip-rip/lib/rip/nodes/invocation.rb:22:in `interpret'
/Users/thomas/Code/rip-rip/lib/rip/nodes/block_body.rb:22:in `block in interpret'
/Users/thomas/Code/rip-rip/lib/rip/nodes/block_body.rb:18:in `map'
/Users/thomas/Code/rip-rip/lib/rip/nodes/block_body.rb:18:in `interpret'
/Users/thomas/Code/rip-rip/lib/rip/core/overload.rb:25:in `call'
/Users/thomas/Code/rip-rip/lib/rip/core/lambda.rb:55:in `call'
/Users/thomas/Code/rip-rip/lib/rip/nodes/invocation.rb:22:in `interpret'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:39:in `block in execute_source'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:38:in `map'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:38:in `execute_source'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:17:in `block in start'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:12:in `loop'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:12:in `start'
/Users/thomas/Code/rip-rip/lib/rip/utilities/repl.rb:29:in `start'
/Users/thomas/Code/rip-rip/lib/rip/cli.rb:26:in `block in repl'
/Users/thomas/Code/rip-rip/lib/rip/cli.rb:94:in `call'
/Users/thomas/Code/rip-rip/lib/rip/cli.rb:94:in `wrap_exceptions'
/Users/thomas/Code/rip-rip/lib/rip/cli.rb:25:in `repl'
/usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
/usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
/usr/local/opt/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
./bin/rip:5:in `<main>'
[15] module > bar2(4, 11)
17
[16] module > exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment