33 lines
575 B
Plaintext
33 lines
575 B
Plaintext
//
|
|
// 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]
|