Skip to content

Commit

Permalink
Update solutions for 0.1.81 cast changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Oct 13, 2024
1 parent 6c1b978 commit 67d5575
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
15 changes: 8 additions & 7 deletions exercises/practice/circular-buffer/.meta/circular-buffer.ys
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!yamlscript/v0

defn run(capacity operations):
buffer =: M(:B V(capacity * [nil]), :P 0)
buffer =: -{:B V(capacity * [nil]), :P 0}
reduce _ buffer operations:
fn(buffer op):
op item pass want =:
Expand All @@ -10,14 +10,14 @@ defn run(capacity operations):
args =:
condp eq op:
-'clear' : -[buffer]
-'read' : L(buffer pass want)
-'write' : L(buffer pass item)
-'overwrite' : L(buffer pass item)
-'read' : -[buffer pass want]
-'write' : -[buffer pass item]
-'overwrite' : -[buffer pass item]
value("op-$op"): args*
=>: true

defn op-clear(buffer):
M: :B V(buffer.B.# * [nil]) :P 0
hash-map: :B V(buffer.B.# * [nil]) :P 0

defn op-read(buffer pass want):
cell =: buffer.B.nth(buffer.P)
Expand All @@ -26,8 +26,9 @@ defn op-read(buffer pass want):
die: S("Can't read:\ " buffer)
when cell != want:
die: "Bad read:\ $cell != $want ($buffer)"
M: :B update-in(buffer.B [buffer.P] constantly(nil))
:P (buffer.P.++ % buffer.B.#)
hash-map:
:B update-in(buffer.B [buffer.P] constantly(nil))
:P (buffer.P.++ % buffer.B.#)

defn op-write(buffer pass item):
B P =: buffer.slice(q(B P))
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/etl/.meta/etl.ys
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
defn transform(legacy):
into {}:
for [score letters] legacy, letter letters:
V: lc(letter) score:N
vector: lc(letter) score:N
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
!yamlscript/v0

pairs =: reverse('()[]{}'):M
opening =: vals(pairs):set
closing =: keys(pairs):set
opening =: vals(pairs):G
closing =: keys(pairs):G

defn is-paired(value):
loop stack [], [char *chars] value:
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/pascals-triangle/.meta/pascals-triangle.ys
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ defn rows(count):
or _ [1]:
when row > 1:
mapv _ (-1 .. row.sub(2)):
\(last(tri).get(_):N.or(0) +
last(tri).get(_.++):N.or(0))
\(last(tri).get(_ 0):N +
last(tri).get(_.++).or(0):N)
2 changes: 1 addition & 1 deletion exercises/practice/raindrops/.meta/raindrops.ys
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!yamlscript/v0

defn convert(number):
ps =: M(3 'Pling' 5 'Plang' 7 'Plong')
ps =: -{3 'Pling' 5 'Plang' 7 'Plong'}
words =:
mapcat _ [3 5 7]:
fn(n):
Expand Down

0 comments on commit 67d5575

Please sign in to comment.