• API
• FAQ
• Tools
• Archive
A Pastebin account makes a great Christmas gift
SHARE
TWEET

# Untitled

a guest Jul 17th, 2018 62 Never
ENDING IN00days00hours00mins00secs

1. (* Problem 5 *)
2. (* numberToName (a)
3. TYPE: int -> string
4. PRE: int 0-99
5. POST: ett heltal representerat av dess bokstaverade motsvarighet
6. EXAMPLES: numberToName(1) -> "ett"
7. EXAMPLES: numberToName(40) -> "fyrtio"
8. *)
9. fun numberToName (a):string =
10.   case a of
11.     0 => "noll"
12.   | 1 => "ett"
13.   | 2 => "två"
14.   | 3 => "tre"
15.   | 4 => "fyra"
16.   | 5 => "fem"
17.   | 6 => "sex"
18.   | 7 => "sju"
19.   | 8 => "åtta"
20.   | 9 => "nio"
21.   | 10 => "tio"
22.   | 11 => "elva"
23.   | 12 => "tolv"
24.   | 13 => "tretton"
25.   | 14 => "fjorton"
26.   | 15 => "femton"
27.   | 16 => "sexton"
28.   | 17 => "sjutton"
29.   | 18 => "artton"
30.   | 19 => "nitton"
31.
32.   | 20 => "tjugo"
33.   | 30 => "trettio"
34.   | 40 => "fyrtio"
35.   | 80 => "åttio"
36.   | 90 => "nittio"
37.
38.   | x => if x > 20 andalso x < 100 then
39. case ord(createchar(Int.toString(x)))*10 of
40.     10 => "tio"
41.   | 11 => "elva"
42.   | 12 => "tolv"
43.   | 13 => "tretton"
44.   | 14 => "fjorton"
45.   | 15 => "femton"
46.   | 16 => "sexton"
47.   | 17 => "sjutton"
48.   | 18 => "artton"
49.   | 19 => "nitton"
50.
51.   | 20 => "tjugo"
52.   | 30 => "trettio"
53.   | 40 => "fyrtio"
54.   | 80 => "åttio"
55.   | 90 => "nittio"
56. else
57. "noll";
58.
59.
60. (50, numberToName(1) = "ett");
61. (51, numberToName(40) = "fyrtio");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top