Skip to content

Commit

Permalink
Move Phead to List Base
Browse files Browse the repository at this point in the history
  • Loading branch information
mariari committed Nov 8, 2024
1 parent 4485bd7 commit dbc3a55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions Stdlib/Data/List.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import Stdlib.Trait.Foldable open using {
fromPolymorphicFoldable;
};

--- π’ͺ(1). Partial function that returns the first element of a ;List;.
phead {A} {{Partial}} : List A -> A
| (x :: _) := x
| nil := fail "head: empty list";

instance
eqListI {A} {{Eq A}} : Eq (List A) :=
let
Expand Down
6 changes: 6 additions & 0 deletions Stdlib/Data/List/Base.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Stdlib.Function open;
import Stdlib.Data.Nat.Base open;
import Stdlib.Data.Maybe.Base open;
import Stdlib.Trait.Ord open;
import Stdlib.Trait.Partial open;
import Stdlib.Data.Pair.Base open;

--- π’ͺ(𝓃). Returns ;true; if the given object elem is in the ;List;.
Expand Down Expand Up @@ -165,6 +166,11 @@ head {A} (defaultValue : A) (list : List A) : A :=
| x :: _ := x
| nil := defaultValue;

--- π’ͺ(1). Partial function that returns the first element of a ;List;.
phead {A} {{Partial}} : List A -> A
| (x :: _) := x
| nil := fail "head: empty list";

syntax iterator any {init := 0; range := 1};

--- π’ͺ(𝓃). Returns ;true; if at least one element of the ;List; satisfies the predicate.
Expand Down

0 comments on commit dbc3a55

Please sign in to comment.