Mercurial > repos > other > SevenLanguagesInSevenWeeks
annotate 1-Ruby/blocks-irb.output @ 97:85a5e9a6ef5c
Add more notes on extracting Just/Maybe values
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 30 Jun 2019 16:09:44 +0100 |
parents | 0374ae06729e |
children |
rev | line source |
---|---|
10
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 blocks.rb(main):001:0> #! /usr/bin/env ruby |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 blocks.rb(main):002:0* |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 blocks.rb(main):003:0* x = 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 => 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 blocks.rb(main):004:0> |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 blocks.rb(main):005:0* # Inline loops |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 blocks.rb(main):006:0* x = x + 1 while x < 10 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 blocks.rb(main):007:0> puts x |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 10 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 blocks.rb(main):008:0> |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 blocks.rb(main):009:0* x = x - 1 until x == 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 blocks.rb(main):010:0> puts x |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 blocks.rb(main):011:0> |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 blocks.rb(main):012:0* # Conventional loops |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 blocks.rb(main):013:0* while x < 10 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 blocks.rb(main):014:1> x = x + 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 blocks.rb(main):015:1> end |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 blocks.rb(main):016:0> puts x |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 10 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 blocks.rb(main):017:0> |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 blocks.rb(main):018:0* until x == 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 blocks.rb(main):019:1> x = x - 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 blocks.rb(main):020:1> end |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 blocks.rb(main):021:0> puts xblocks.rb(main):021:0> |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 1 |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 => nil |
0374ae06729e
Start playing around with loop block definitions
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 blocks.rb(main):021:0> |