Skip to content

Commit

Permalink
Add queue to standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
cruessler committed Feb 6, 2024
1 parent 80b46ad commit 440a5af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/elm/StandardLibrary.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The only thing omitted so far are the calls to `bury` because burying is not yet
implemented in elm-logo.
[combine]: https://github.com/jrincayc/ucblogo-code/blob/master/logolib/combine
[queue]: https://github.com/jrincayc/ucblogo-code/blob/master/logolib/queue
[reverse]: https://github.com/jrincayc/ucblogo-code/blob/master/logolib/reverse
-}
Expand All @@ -24,6 +25,10 @@ if wordp :those [output word :this :those]
output fput :this :those
end
to queue :the.queue.name :the.item.value
make :the.queue.name lput :the.item.value thing :the.queue.name
end
to reverse :in [:out ifelse listp :in [[]] ["]]
if emptyp :in [output :out]
output (reverse bf :in combine first :in :out)
Expand Down
3 changes: 3 additions & 0 deletions tests/Test/Run/StandardLibrary.elm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ functions =
, printsLine "print combine \"a [b [c]]" "a b [c]"
, printsLine "print combine [a] [b c]" "[a] b c"
]
, describe "queue" <|
[ printsLine "make \"q [] queue \"q 1 queue \"q [2] print :q" "1 [2]"
]
, describe "reverse" <|
[ printsLine "print reverse [a b c d]" "d c b a"
, printsLine "print reverse \"word" "drow"
Expand Down

0 comments on commit 440a5af

Please sign in to comment.