Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,8 +1,8 @@
let string_repeat s n =
let len = String.length s in
let res = String.create(n * len) in
let len = Bytes.length s in
let res = Bytes.create(n * len) in
for i = 0 to pred n do
String.blit s 0 res (i * len) len;
Bytes.blit s 0 res (i * len) len
done;
(res)
Bytes.to_string res (* not stricly necessary, the bytes type is equivalent to string except mutability *)
;;

View file

@ -1,2 +1 @@
# string_repeat "Hiuoa" 3 ;;
- : string = "HiuoaHiuoaHiuoa"
val string_repeat : bytes -> int -> string = <fun>

View file

@ -1,3 +1,2 @@
let string_repeat s n =
String.concat "" (Array.to_list (Array.make n s))
;;
# string_repeat "Hiuoa" 3 ;;
- : string = "HiuoaHiuoaHiuoa"

View file

@ -1,3 +1,3 @@
let string_repeat s n =
Array.fold_left (^) "" (Array.make n s)
String.concat "" (Array.to_list (Array.make n s))
;;

View file

@ -1 +1,3 @@
String.make 5 '*'
let string_repeat s n =
Array.fold_left (^) "" (Array.make n s)
;;

View file

@ -0,0 +1 @@
String.make 5 '*'