shithub: mc

Download patch

ref: 56251d257472a214910a0d0861cae5090bdd83d9
parent: d4c21dfa1254208ac352246b3e36be1bde15a662
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Apr 29 19:27:56 EDT 2016

Add slput

--- a/lib/std/slput.myr
+++ b/lib/std/slput.myr
@@ -3,8 +3,8 @@
 use "die"
 
 pkg std =
-	generic slput	: (sl : @a[:], idx : size, elt : @a	-> @a[:])
-	generic sldel	: (sl : @a[:], idx : size	-> @a[:])
+	generic slput	: (sl : @a[:]#, idx : size, elt : @a	-> @a[:])
+	generic sldel	: (sl : @a[:]#, idx : size	-> @a[:])
 ;;
 
 generic slput = {sl, idx, elt
@@ -11,18 +11,18 @@
 	var i
 	var len
 
-	len = sl.len
-	slgrow(&sl, sl.len + 1)
+	len = sl#.len
+	slgrow(sl, sl#.len + 1)
 	for i = len - 1; i >= idx; i--
-		sl[i + 1] = sl[i]
+		sl#[i + 1] = sl#[i]
 	;;
-	sl[idx] = elt
-	-> sl
+	sl#[idx] = elt
+	-> sl#
 }
 
 generic sldel = {sl, idx
-	for var i = idx; i < sl.len - 1; i++
-		sl[i] = sl[i + 1]
+	for var i = idx; i < sl#.len - 1; i++
+		sl#[i] = sl#[i + 1]
 	;;
-	-> sl[:sl.len - 1]
+	-> sl#[:sl#.len - 1]
 }