Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
32
Task/Repeat-a-string/ATS/repeat-a-string.ats
Normal file
32
Task/Repeat-a-string/ATS/repeat-a-string.ats
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// How to compile:
|
||||
// patscc -DATS_MEMALLOC_LIBC -o string_repeat string_repeat.dats
|
||||
//
|
||||
|
||||
#include
|
||||
"share/atspre_staload.hats"
|
||||
|
||||
fun
|
||||
string_repeat
|
||||
(
|
||||
x: string, n: intGte(0)
|
||||
) : Strptr1 = res where
|
||||
{
|
||||
val xs =
|
||||
list_make_elt<string>(n, x)
|
||||
val res = stringlst_concat($UNSAFE.list_vt2t(xs))
|
||||
val ((*freed*)) = list_vt_free(xs)
|
||||
} (* end of [string_repeat] *)
|
||||
|
||||
(* ****** ****** *)
|
||||
|
||||
implement
|
||||
main0 () = let
|
||||
//
|
||||
val ha5 = string_repeat("ha", 5)
|
||||
val ((*void*)) = println! ("ha5 = \"", ha5, "\"")
|
||||
val ((*freed*)) = strptr_free (ha5)
|
||||
//
|
||||
in
|
||||
// nothing
|
||||
end // end of [main0]
|
||||
5
Task/Repeat-a-string/ColdFusion/repeat-a-string.cfm
Normal file
5
Task/Repeat-a-string/ColdFusion/repeat-a-string.cfm
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<cfset word = 'ha'>
|
||||
<Cfset n = 5>
|
||||
<Cfoutput>
|
||||
<Cfloop from="1" to="#n#" index="i">#word#</Cfloop>
|
||||
</Cfoutput>
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
(defun repeat-string (n string)
|
||||
(with-output-to-string (stream)
|
||||
(loop repeat n do (write-string string stream))))
|
||||
|
||||
(princ (repeat-string 5 "hi"))
|
||||
|
|
|
|||
|
|
@ -1 +1,9 @@
|
|||
(make-string 5 :initial-element #\X)
|
||||
(defun repeat-string (n string
|
||||
&aux
|
||||
(len (length string))
|
||||
(result (make-string (* n len)
|
||||
:element-type (array-element-type string))))
|
||||
(loop repeat n
|
||||
for i from 0 by len
|
||||
do (setf (subseq result i (+ i len)) string))
|
||||
result)
|
||||
|
|
|
|||
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-3.lisp
Normal file
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-3.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(princ (repeat-string 5 "hi"))
|
||||
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-4.lisp
Normal file
1
Task/Repeat-a-string/Common-Lisp/repeat-a-string-4.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-string 5 :initial-element #\X)
|
||||
|
|
@ -1 +1,7 @@
|
|||
StrUtils.DupeString
|
||||
function RepeatStr(const s: string; i: Cardinal): string;
|
||||
begin
|
||||
if i = 0 then
|
||||
result := ''
|
||||
else
|
||||
result := s + RepeatStr(s, i-1)
|
||||
end;
|
||||
|
|
|
|||
1
Task/Repeat-a-string/Delphi/repeat-a-string-4.delphi
Normal file
1
Task/Repeat-a-string/Delphi/repeat-a-string-4.delphi
Normal file
|
|
@ -0,0 +1 @@
|
|||
StrUtils.DupeString
|
||||
6
Task/Repeat-a-string/Eiffel/repeat-a-string.e
Normal file
6
Task/Repeat-a-string/Eiffel/repeat-a-string.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
repeat_string(a_string: STRING; times: INTEGER): STRING
|
||||
require
|
||||
times_positive: times > 0
|
||||
do
|
||||
Result := a_string.multiply(times)
|
||||
end
|
||||
1
Task/Repeat-a-string/Elixir/repeat-a-string.elixir
Normal file
1
Task/Repeat-a-string/Elixir/repeat-a-string.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
String.duplicate("ha", 5)
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
Concatenation(List([1 .. 10], n -> "BOB "));
|
||||
# "BOB BOB BOB BOB BOB BOB BOB BOB BOB BOB "
|
||||
Concatenation(ListWithIdenticalEntries(10, "BOB "));
|
||||
"BOB BOB BOB BOB BOB BOB BOB BOB BOB BOB "
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
cycle "ha"
|
||||
[1..5] *> "ha"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
replicate 5 '*'
|
||||
cycle "ha"
|
||||
|
|
|
|||
1
Task/Repeat-a-string/Haskell/repeat-a-string-5.hs
Normal file
1
Task/Repeat-a-string/Haskell/repeat-a-string-5.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
replicate 5 '*'
|
||||
5
Task/Repeat-a-string/JavaScript/repeat-a-string-1.js
Normal file
5
Task/Repeat-a-string/JavaScript/repeat-a-string-1.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
String.prototype.repeat = function(n) {
|
||||
return new Array(1 + (n || 0)).join(this);
|
||||
}
|
||||
|
||||
console.log("ha".repeat(5)); // hahahahaha
|
||||
1
Task/Repeat-a-string/JavaScript/repeat-a-string-2.js
Normal file
1
Task/Repeat-a-string/JavaScript/repeat-a-string-2.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log("ha".repeat(5)); // hahahahaha
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
String.prototype.repeat = function(n) {
|
||||
return new Array(1 + n).join(this);
|
||||
}
|
||||
|
||||
alert("ha".repeat(5)); // hahahahaha
|
||||
1
Task/Repeat-a-string/PARI-GP/repeat-a-string-2.pari
Normal file
1
Task/Repeat-a-string/PARI-GP/repeat-a-string-2.pari
Normal file
|
|
@ -0,0 +1 @@
|
|||
repeat(s,n)=concat(vector(n,i, s));
|
||||
12
Task/Repeat-a-string/RapidQ/repeat-a-string.rapidq
Normal file
12
Task/Repeat-a-string/RapidQ/repeat-a-string.rapidq
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'For a single char
|
||||
showmessage String$(10, "-")
|
||||
|
||||
'For strings with more than one char
|
||||
function Repeat$(Expr as string, Count as integer) as string
|
||||
dim x as integer
|
||||
for x = 1 to Count
|
||||
Result = Result + Expr
|
||||
next
|
||||
end function
|
||||
|
||||
showmessage Repeat$("ha", 5)
|
||||
|
|
@ -0,0 +1 @@
|
|||
FileContents = "".PadRight(FileSizeBytes, "X")
|
||||
|
|
@ -0,0 +1 @@
|
|||
FileContents = "".PadRight(3, "XO-")
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
FileContents = "X".PadRight(FileSizeBytes - 1, "X")
|
||||
|
||||
Where:
|
||||
|
||||
* FileContents is the string to populate
|
||||
* FileSizeBytes is the number of repetitions (Remember that "-1" is valid as we have already specified the first character as being "X", which is to be padded on.
|
||||
Loading…
Add table
Add a link
Reference in a new issue