File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ # Write a lambda which takes an integer and square it
2+ square = -> ( a ) { a **2 }
3+
4+ # Write a lambda which takes an integer and increment it by 1
5+ plus_one = -> ( b ) { b +1 }
6+
7+ # Write a lambda which takes an integer and multiply it by 2
8+ into_2 = -> ( c ) { c *2 }
9+
10+ # Write a lambda which takes two integers and adds them
11+ adder = -> ( d , e ) { d +e }
12+
13+ # Write a lambda which takes a hash and returns an array of hash values
14+ values_only = -> ( f ) { f . values }
15+
16+
17+ input_number_1 = gets . to_i
18+ input_number_2 = gets . to_i
19+ input_hash = eval ( gets )
20+
21+ a = square . ( input_number_1 ) ; b = plus_one . ( input_number_2 ) ; c = into_2 . ( input_number_1 ) ;
22+ d = adder . ( input_number_1 , input_number_2 ) ; e = values_only . ( input_hash )
23+
24+ p a ; p b ; p c ; p d ; p e
You can’t perform that action at this time.
0 commit comments