File: libats_ML_string.dats

package info (click to toggle)
ats2-lang 0.4.2-4
  • links: PTS
  • area: main
  • in suites:
  • size: 40,524 kB
  • sloc: ansic: 389,898; makefile: 7,138; javascript: 1,852; lisp: 811; sh: 657; php: 573; python: 387; perl: 365
file content (90 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(*
** for testing [libats/ML/string]
*)

(* ****** ****** *)
//
#include "share/atspre_staload.hats"
//
(* ****** ****** *)

staload UN = "prelude/SATS/unsafe.sats"

(* ****** ****** *)

staload "libats/ML/SATS/string.sats"

(* ****** ****** *)
//
staload _(*anon*) = "libats/ML/DATS/array0.dats"
staload _(*anon*) = "libats/ML/DATS/string.dats"
//
(* ****** ****** *)

val alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

(* ****** ****** *)

val () =
{
val () = assertloc (itoa (12345) = "12345")
} (* end of [val] *)

(* ****** ****** *)

val () =
{
//
val () = assertloc (length (alphabet) = 26)
val () = assertloc (alphabet = string_copy (alphabet))
val () = assertloc (alphabet = string_make_substring (alphabet, (i2sz)0, (i2sz)26))
//
val () = assertloc (alphabet[0] = 'A')
val () = assertloc (alphabet[25] = 'Z')
//
} // end of [val]

(* ****** ****** *)

val () =
{
//
val ds =
string_tabulate
(
  i2sz(10)
, lam i => $UN.cast{charNZ}('0'+sz2i(i))
) (* end of [val] *)
//
val out = stdout_ref
val () = fprintln! (out, "digits = ", ds)
//
val () =
string_foreach (ds+ds, lam c => fprint(out, c))
//
val ((*void*)) = fprint_newline (out)
//
} (* end of [val] *)

(* ****** ****** *)

val () =
{
//
val str = ""
val cs = string_explode (str)
val () = assertloc (str = string_implode(cs))
//
val str = "abcde"
val cs = string_explode (str)
val () = assertloc (str = string_implode(cs))
//
} (* end of [val] *)

(* ****** ****** *)

implement main0 () = ()

(* ****** ****** *)

(* end of [libats_ML_string.dats] *)