Mercurial > repos > tabletprog
annotate modules/option.tp @ 344:7de6ac24eb64
Add map to dict hash
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 08 Apr 2015 19:29:22 -0700 |
parents | 1458c069c715 |
children | fd4e0bf5bd9f |
rev | line source |
---|---|
275
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 { |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 _none <- #{ |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 value:none <- :ifval :ifnone { |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 ifnone: |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 } |
338
1458c069c715
Added "value" method to option value and option none. It behaves similarly to value:none, except the none case just propagates the none value and the value case wraps the result in an option value
Michael Pavone <pavone@retrodev.com>
parents:
290
diff
changeset
|
6 value <- :ifval { self } |
290
38ca63e0a62e
Added value? and none? methods to option value and option none
Michael Pavone <pavone@retrodev.com>
parents:
275
diff
changeset
|
7 value? <- { false } |
38ca63e0a62e
Added value? and none? methods to option value and option none
Michael Pavone <pavone@retrodev.com>
parents:
275
diff
changeset
|
8 none? <- { true } |
275
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 } |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #{ |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 value <- :v { |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #{ |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 value:none <- :ifval :ifnone { |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 ifval: v |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 } |
338
1458c069c715
Added "value" method to option value and option none. It behaves similarly to value:none, except the none case just propagates the none value and the value case wraps the result in an option value
Michael Pavone <pavone@retrodev.com>
parents:
290
diff
changeset
|
16 value <- :ifval { |
1458c069c715
Added "value" method to option value and option none. It behaves similarly to value:none, except the none case just propagates the none value and the value case wraps the result in an option value
Michael Pavone <pavone@retrodev.com>
parents:
290
diff
changeset
|
17 option value: (ifval: ) |
1458c069c715
Added "value" method to option value and option none. It behaves similarly to value:none, except the none case just propagates the none value and the value case wraps the result in an option value
Michael Pavone <pavone@retrodev.com>
parents:
290
diff
changeset
|
18 } |
290
38ca63e0a62e
Added value? and none? methods to option value and option none
Michael Pavone <pavone@retrodev.com>
parents:
275
diff
changeset
|
19 value? <- { true } |
38ca63e0a62e
Added value? and none? methods to option value and option none
Michael Pavone <pavone@retrodev.com>
parents:
275
diff
changeset
|
20 none? <- { false } |
275
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 } |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 } |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 none <- { _none } |
d83647152485
Added option module which was omitted in commit of SDL work
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 } |
290
38ca63e0a62e
Added value? and none? methods to option value and option none
Michael Pavone <pavone@retrodev.com>
parents:
275
diff
changeset
|
25 } |