Skip to content

Commit

Permalink
add/fix some stdlib functions
Browse files Browse the repository at this point in the history
  • Loading branch information
simvux committed Oct 25, 2024
1 parent 8fb7e0f commit 6976d51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions luminapath/std/list/lib.lm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ pub fn take at list as uint, List a -> List a =
let (lhs, rhs) = split_at at list
in lhs

pub fn skip at list as uint, List a -> List a =
let (lhs, rhs) = split_at at list
in rhs

pub fn split_at at list as uint, List a -> (List a, List a) =
if at == 0 then
(Nil, list)
Expand Down
2 changes: 1 addition & 1 deletion luminapath/std/list/slice.lm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn map f slice as fn(a -> b), Slice a -> Slice b =

// Splits the slice at the given index.
pub fn split_at at slice as uint, Slice a -> (Slice a, Slice a) =
(take at slice, skip (at+1) slice)
(take at slice, skip (at) slice)

pub fn take n slice as uint, Slice a -> Slice a =
{ slice ~ len @ len = min n len }
Expand Down
3 changes: 3 additions & 0 deletions luminapath/std/string/lib.lm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ impl Stringable for string
pub fn break f str as fn(u8 -> bool), string -> (string, string) =
Stringable:split_while str #f

pub fn skip n {inner} as uint, string -> string =
inner . list:skip n . fromBytes

pub fn fromByteVec vec as Vec u8 -> string =
{ string | inner = vec . to_slice . to_list }

Expand Down

0 comments on commit 6976d51

Please sign in to comment.