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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue