June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,19 +1,22 @@
|
|||
: 24game
|
||||
import: mapping
|
||||
|
||||
: game
|
||||
| l expr w n i |
|
||||
ListBuffer init(4, #[ 9 rand ]) ->l
|
||||
4 #[ 9 rand ] Array init ->l
|
||||
|
||||
System.Out "Digits : " << l << " --> RPN Expression for 24 : " << drop
|
||||
System.Console askln ->expr
|
||||
System.Console accept ->expr
|
||||
|
||||
expr words forEach: w [
|
||||
w "+" == ifTrue: [ + continue ]
|
||||
w "-" == ifTrue: [ - continue ]
|
||||
w "*" == ifTrue: [ * continue ]
|
||||
w "/" == ifTrue: [ asFloat / continue ]
|
||||
w "/" == ifTrue: [ >float / continue ]
|
||||
|
||||
w asInteger dup ->n ifNull: [ System.Out "Word " << w << " not allowed " << cr break ]
|
||||
l indexOf(n) dup ->i ifNull: [ System.Out "Integer " << n << " is wrong " << cr break ]
|
||||
w >integer dup ->n ifNull: [ System.Out "Word " << w << " not allowed " << cr break ]
|
||||
n l indexOf dup ->i ifNull: [ System.Out "Integer " << n << " is wrong " << cr break ]
|
||||
n l put(i, null)
|
||||
]
|
||||
l conform(#isNull) ifFalse: [ "Sorry, all numbers must be used..." println return ]
|
||||
24 == ifTrue: [ "You won !" ] else: [ "You loose..." ] println ;
|
||||
#null? l conform? ifFalse: [ "Sorry, all numbers must be used..." . return ]
|
||||
24 if=: [ "You won !" ] else: [ "You loose..." ] .
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue