Skip to content
Browse files

Add string times integer.

  • Loading branch information...
1 parent 45e8604 commit 94b250456d39fe0988044b21e339dc163ea4cc0c nineties committed Mar 25, 2013
Showing with 12 additions and 1 deletion.
  1. +12 −1 rowl1/rowl1-string.rlc
View
13 rowl1/rowl1-string.rlc
@@ -2,7 +2,7 @@
; rowl - 1st generation
; Copyright (C) 2010 nineties
;
-; $Id: rowl1-string.rlc 2013-02-23 14:39:22 nineties $
+; $Id: rowl1-string.rlc 2013-03-25 22:30:35 nineties $
;
(import "rlvm-compile")
@@ -53,6 +53,16 @@
(return (strcat a b))
))
+(fun s_mul (a n) (
+ (= n (unbox n))
+ (var m (strlen a))
+ (var s (allocate_string (* m n)))
+ (for i 0 n (do
+ (strcpy (+ s (* m i)) a)
+ ))
+ (return s)
+ ))
+
(fun s_unescape (s) (
(= s (strdup s))
(unescape_string_d s)
@@ -162,6 +172,7 @@
(add_function2 std (to_sym "add") stringT stringT s_add 0)
(add_function2 std (to_sym "add") stringT DontCare s_add2 0)
(add_function2 std (to_sym "add") DontCare stringT s_add2 0)
+ (add_function2 std (to_sym "mul") stringT intT s_mul 0)
(add_function1 std (to_sym "char") intT s_char 0)
(add_function1 std (to_sym "code") stringT s_code 0)

0 comments on commit 94b2504

Please sign in to comment.
Something went wrong with that request. Please try again.