Skip to content

Commit

Permalink
WIP #85. Implement deep-take.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgpy3 committed Feb 18, 2016
1 parent 221b455 commit 64e6d8c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions prelude/prelude.map
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ nil = ()

cons value list = (:head value :tail list)

deep-take keys structure = [
if [empty? keys]
structure
[deep-take
[:tail keys]
[take [:head keys] structure]]
]

-- length : list a -> nat
length values = [
if [empty? values]
Expand Down Expand Up @@ -728,6 +736,22 @@ cases = (|
:expected [mult [add three three] [add three four]]
)
)
(
:testing :deep-take-given-no-keys
:where (
:should-be :equal
:actual [deep-take nil (:a (:b :c))]
:expected (:a (:b :c))
)
)
(
:testing :deep-take-given-some-keys
:where (
:should-be :equal
:actual [deep-take (| :head :a () |) (| (:a (() :c)) two three |)]
:expected :c
)
)
|)

apply-case case =
Expand Down

0 comments on commit 64e6d8c

Please sign in to comment.