Skip to content

Commit

Permalink
No longer need dash before string keys for case/condp
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Nov 1, 2024
1 parent 7f4582e commit 1557df5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions exercises/practice/bank-account/.meta/bank-account.ys
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ defn bank-account(operations):
reduce _ closed operations:
fn(bal op):
case op.operation:
-'open':
'open':
if closed?(bal): 0, die('account already open')
-'close':
'close':
if closed?(bal): die('account not open'), closed
-'balance':
'balance':
if closed?(bal): die('account not open'), bal
-'deposit':
'deposit':
cond:
closed?(bal): die('account not open')
op.amount <= 0: die('amount must be greater than 0')
else: bal + op.amount
-'withdraw':
'withdraw':
cond:
closed?(bal): die('account not open')
op.amount <= 0: die('amount must be greater than 0')
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/circular-buffer/.meta/circular-buffer.ys
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ defn run(capacity operations):
'should_succeed' 'expected')
args =:
condp eq op:
-'clear' : -[buffer]
-'read' : -[buffer pass want]
-'write' : -[buffer pass item]
-'overwrite' : -[buffer pass item]
'clear' : -[buffer]
'read' : -[buffer pass want]
'write' : -[buffer pass item]
'overwrite' : -[buffer pass item]
value("op-$op"): args*
=>: -{}

Expand Down
24 changes: 12 additions & 12 deletions exercises/practice/yacht/.meta/yacht.ys
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ defn score(dice category):
counts =: dice:frequencies
counts2 =: counts:set/map-invert
case category:
-'yacht': dice-set.#.eq(1).and(50).or(0)
-'choice': dice:sum
-'little straight': dice-set.eq([1 2 3 4 5]).and(30).or(0)
-'big straight': dice-set.eq([2 3 4 5 6]).and(30).or(0)
-'four of a kind': counts2(4 counts2(5 0)) * 4
-'full house': (counts2.2 && counts2.3).and(dice:sum).or(0)
-'ones' : counts(1 0) * 1
-'twos' : counts(2 0) * 2
-'threes': counts(3 0) * 3
-'fours' : counts(4 0) * 4
-'fives' : counts(5 0) * 5
-'sixes' : counts(6 0) * 6
'full house': (counts2.2 && counts2.3).and(dice:sum).or(0)
'little straight': dice-set.eq([1 2 3 4 5]).and(30).or(0)
'big straight' : dice-set.eq([2 3 4 5 6]).and(30).or(0)
'four of a kind' : counts2(4 counts2(5 0)) * 4
'yacht' : dice-set.#.eq(1).and(50).or(0)
'choice': dice:sum
'ones' : counts(1 0) * 1
'twos' : counts(2 0) * 2
'threes': counts(3 0) * 3
'fours' : counts(4 0) * 4
'fives' : counts(5 0) * 5
'sixes' : counts(6 0) * 6

0 comments on commit 1557df5

Please sign in to comment.