Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
3
Task/Repeat-a-string/AutoIt/repeat-a-string.autoit
Normal file
3
Task/Repeat-a-string/AutoIt/repeat-a-string.autoit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include <String.au3>
|
||||
|
||||
ConsoleWrite(_StringRepeat("ha", 5) & @CRLF)
|
||||
|
|
@ -1 +1,2 @@
|
|||
(princ (repeat-string 5 "hi"))
|
||||
(defun repeat-string (n string)
|
||||
(format nil "~V@{~a~:*~}" n string))
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(make-string 5 :initial-element #\X)
|
||||
(princ (repeat-string 5 "hi"))
|
||||
|
|
|
|||
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-5.lisp
Normal file
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-5.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-string 5 :initial-element #\X)
|
||||
2
Task/Repeat-a-string/DCL/repeat-a-string.dcl
Normal file
2
Task/Repeat-a-string/DCL/repeat-a-string.dcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ write sys$output f$fao( "!AS!-!AS!-!AS!-!AS!-!AS", "ha" )
|
||||
$ write sys$output f$fao( "!12*d" )
|
||||
12
Task/Repeat-a-string/JavaScript/repeat-a-string-3.js
Normal file
12
Task/Repeat-a-string/JavaScript/repeat-a-string-3.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function nreps(s, n) {
|
||||
var o = '';
|
||||
if (n < 1) return o;
|
||||
while (n > 1) {
|
||||
if (n & 1) o += s;
|
||||
n >>= 1;
|
||||
s += s;
|
||||
}
|
||||
return o + s;
|
||||
}
|
||||
|
||||
nreps('ha', 50000);
|
||||
3
Task/Repeat-a-string/Kotlin/repeat-a-string.kotlin
Normal file
3
Task/Repeat-a-string/Kotlin/repeat-a-string.kotlin
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fun main(args: Array<String>) {
|
||||
println("ha".repeat(5))
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
function repeats(s, n) return n > 0 and s .. repeat(s, n-1) or "" end
|
||||
function repeats(s, n) return n > 0 and s .. repeats(s, n-1) or "" end
|
||||
|
|
|
|||
|
|
@ -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 '*'
|
||||
1
Task/Repeat-a-string/Rust/repeat-a-string.rust
Normal file
1
Task/Repeat-a-string/Rust/repeat-a-string.rust
Normal file
|
|
@ -0,0 +1 @@
|
|||
std::iter::repeat("ha").take(5).collect::<String>(); // ==> "hahahahaha"
|
||||
1
Task/Repeat-a-string/Smalltalk/repeat-a-string-7.st
Normal file
1
Task/Repeat-a-string/Smalltalk/repeat-a-string-7.st
Normal file
|
|
@ -0,0 +1 @@
|
|||
(String new:n) atAllPut:$*
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
width=72; char='='
|
||||
head -c ${width} < /dev/zero | tr '\0' "$char"
|
||||
len=12; str='='
|
||||
repeat $len printf "$str"
|
||||
|
|
|
|||
2
Task/Repeat-a-string/UNIX-Shell/repeat-a-string-6.sh
Normal file
2
Task/Repeat-a-string/UNIX-Shell/repeat-a-string-6.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
width=72; char='='
|
||||
head -c ${width} < /dev/zero | tr '\0' "$char"
|
||||
Loading…
Add table
Add a link
Reference in a new issue