summaryrefslogtreecommitdiff
path: root/libstd/slput.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-05-14 10:50:02 -0400
committerOri Bernstein <ori@eigenstate.org>2014-05-14 10:50:02 -0400
commit7b45d388ae914b853e330a1ce35881e4f7910fdf (patch)
tree629f854b89466cdbc9e187f2dffdf14f6639954d /libstd/slput.myr
parent8c7bac5ae4b0611bebf0e5c88ee483e406bece86 (diff)
downloadmc-7b45d388ae914b853e330a1ce35881e4f7910fdf.tar.gz
Rename files to match function names.
slinsert.myr contained slput(). Rename so that it matches the function.
Diffstat (limited to 'libstd/slput.myr')
-rw-r--r--libstd/slput.myr21
1 files changed, 21 insertions, 0 deletions
diff --git a/libstd/slput.myr b/libstd/slput.myr
new file mode 100644
index 0000000..c1a7d33
--- /dev/null
+++ b/libstd/slput.myr
@@ -0,0 +1,21 @@
+use "types.use"
+use "alloc.use"
+use "die.use"
+use "fmt.use"
+
+pkg std =
+ generic slput : (sl : @a[:], idx : size, elt : @a -> @a[:])
+;;
+
+generic slput = {sl, idx, elt
+ var i
+ var len
+
+ len = sl.len
+ sl = slgrow(sl, sl.len + 1)
+ for i = len - 1; i >= idx; i--
+ sl[i + 1] = sl[i]
+ ;;
+ sl[idx] = elt
+ -> sl
+}