shithub: mc

Download patch

ref: dc52d457fd6efb778cb91a7912e5c1329d8c34ef
parent: dd0cb53f937c9a47c76ac6f4c2913287b2e65d02
author: Ori Bernstein <[email protected]>
date: Fri Oct 18 20:47:14 EDT 2013

Add sldup() function to standard library.

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -17,6 +17,7 @@
     rand.myr \
     slappend.myr \
     slcp.myr \
+    sldup.myr \
     sleq.myr \
     sljoin.myr \
     slurp.myr \
--- /dev/null
+++ b/libstd/sldup.myr
@@ -1,0 +1,15 @@
+use "alloc.use"
+use "die.use"
+use "slcp.use"
+
+pkg std =
+	generic sldup : (sl : @a[:] -> @a[:])
+;;
+
+generic sldup = {sl
+	var ret
+
+	ret = slalloc(sl.len)
+	slcp(ret, sl)
+	-> ret
+}