shithub: sl

Download patch

ref: 978d1ce735401504423dbc4cda210936b7accc1b
parent: 1b6ccc7c82c2700ef8c98e97bf1f231850f51c10
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Apr 25 06:02:54 EDT 2025

str-rep: simplify, make it fail on positive non-integers

--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -487,8 +487,8 @@
 e!- #fn("n2I1B3B041=101?04N4?1@\x1d/40:" #() reverse!- 7) reverse-
             #fn("n21J400:701<0P1=62:" #(reverse-) reverse- 7) rune? #fn("n12005121Q:" #(#fn(type-of)
                                                                                         rune) rune? 6)
-     self-evaluating? #fn("n120051S;3Z040H;36040RS;JK0421051;3A040R;3:04022051Q:" #(#fn(gensym?)
-  #fn(const?) #fn(top-level-value)) self-evaluating? 7)
+     self-evaluating? #fn("n120051S;3Z040H;36040RS;JK0421051;3A040R;3:04022051Q:" #(#fn(gensym?)
+  #fn(const?) #fn(top-level-value)) self-evaluating? 7)
 arate-doc-from-body #fn("\x8710002000W1000J60q?14I2021?65140<0=2287513F01JB0883=07388871P62:13X02487513O086258751513B07388=8788<P1P62:761510P:" #(#0#
   #fn("n1r520051L2;3i04210K5222Q;3[04210r25223Q;3L04210r35224Q;3=04210r45225Q:" #(#fn(str-length)
                                                                                   #fn(str-rune)
--- a/src/system.sl
+++ b/src/system.sl
@@ -1092,13 +1092,9 @@
     (io->str b)))
 
 (def (str-rep s k)
-  (cond ((< k 4)
-         (cond ((<= k 0) "")
-               ((=  k 1) (str s))
-               ((=  k 2) (str s s))
-               (else     (str s s s))))
+  (cond ((<= k 0) "")
         ((odd? k) (str s (str-rep s (- k 1))))
-        (else     (str-rep (str s s) (/ k 2)))))
+        (else     (str-rep (str s s) (div0 k 2)))))
 
 (def (str-lpad s n c)
   (str (str-rep c (- n (str-length s))) s))