Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -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 *)
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
# string_repeat "Hiuoa" 3 ;;
|
||||
- : string = "HiuoaHiuoaHiuoa"
|
||||
val string_repeat : bytes -> int -> string = <fun>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
let string_repeat s n =
|
||||
String.concat "" (Array.to_list (Array.make n s))
|
||||
;;
|
||||
# string_repeat "Hiuoa" 3 ;;
|
||||
- : string = "HiuoaHiuoaHiuoa"
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
String.make 5 '*'
|
||||
let string_repeat s n =
|
||||
Array.fold_left (^) "" (Array.make n s)
|
||||
;;
|
||||
|
|
|
|||
1
Task/Repeat-a-string/OCaml/repeat-a-string-6.ocaml
Normal file
1
Task/Repeat-a-string/OCaml/repeat-a-string-6.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
String.make 5 '*'
|
||||
Loading…
Add table
Add a link
Reference in a new issue