Skip to content

Commit

Permalink
Lib: Add list::set
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiriVulpes committed Dec 16, 2024
1 parent f4ca4d3 commit 23d03d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/function/list.chiri
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
list/size
list/join
list/map
list/set
16 changes: 16 additions & 0 deletions lib/function/list/set.chiri
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#function set with t!* returns list!t:
#list!t list
#int at
#t value

#if at < list::length * -1:
#error function: #{at} exceeds list bounds

#if at >= list::length:
#error function: #{at} exceeds list length #{list::length}

#if at == -1:
#return [...list[..at], value

#int after = at + 1
#return [...list[..at], value, ...list[after..]

0 comments on commit 23d03d4

Please sign in to comment.