Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View 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]

View file

@ -0,0 +1,5 @@
<cfset word = 'ha'>
<Cfset n = 5>
<Cfoutput>
<Cfloop from="1" to="#n#" index="i">#word#</Cfloop>
</Cfoutput>

View file

@ -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"))

View file

@ -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)

View file

@ -0,0 +1 @@
(princ (repeat-string 5 "hi"))

View file

@ -0,0 +1 @@
(make-string 5 :initial-element #\X)

View file

@ -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;

View file

@ -0,0 +1 @@
StrUtils.DupeString

View 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

View file

@ -0,0 +1 @@
String.duplicate("ha", 5)

View file

@ -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 "

View file

@ -1 +1 @@
cycle "ha"
[1..5] *> "ha"

View file

@ -1 +1 @@
replicate 5 '*'
cycle "ha"

View file

@ -0,0 +1 @@
replicate 5 '*'

View file

@ -0,0 +1,5 @@
String.prototype.repeat = function(n) {
return new Array(1 + (n || 0)).join(this);
}
console.log("ha".repeat(5)); // hahahahaha

View file

@ -0,0 +1 @@
console.log("ha".repeat(5)); // hahahahaha

View file

@ -1,5 +0,0 @@
String.prototype.repeat = function(n) {
return new Array(1 + n).join(this);
}
alert("ha".repeat(5)); // hahahahaha

View file

@ -0,0 +1 @@
repeat(s,n)=concat(vector(n,i, s));

View 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)

View file

@ -0,0 +1 @@
FileContents = "".PadRight(FileSizeBytes, "X")

View file

@ -0,0 +1 @@
FileContents = "".PadRight(3, "XO-")

View file

@ -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.