blob: 2d863cedcc54cdcd8475aba0f7d839cfb136d846 (
about) (
plain)
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
|
module Miranda(cjustify, lay, layn, limit, ljustify, merge, rep, rjustify, spaces,
{-force,seq,-}sort) where
--import UnsafeDirty
import QSort
cjustify :: Int -> String -> String
cjustify n s = spaces l ++ s ++ spaces r
where
m = n - length s
l = m `div` 2
r = m - l
{-
index :: [a] -> [Int]
index xs = f xs 0
where f [] n = []
f (_:xs) n = n : f xs (n+1)
-}
lay :: [String] -> String
lay = concat . map (++"\n")
layn :: [String] -> String
layn = concat . zipWith f [1..]
where
f :: Int -> String -> String
f n x = rjustify 4 (show n) ++ ") " ++ x ++ "\n"
limit :: (Eq a) => [a] -> a
limit (x:y:ys) | x == y = x
| otherwise = limit (y:ys)
limit _ = error "Miranda.limit: bad use"
ljustify :: Int -> String -> String
ljustify n s = s ++ spaces (n - length s)
merge :: (Ord a) => [a] -> [a] -> [a]
merge [] ys = ys
merge xs [] = xs
merge xxs@(x:xs) yys@(y:ys) | x <= y = x : merge xs yys
| otherwise = y : merge xxs ys
rep :: Int -> b -> [b]
rep n x = take n (repeat x)
rjustify :: Int -> String -> String
rjustify n s = spaces (n - length s) ++ s
spaces :: Int -> String
spaces 0 = ""
spaces n = ' ' : spaces (n-1)
-------------
arctan x = atan x
code c = ord c
converse f a b = flip f a b
decode n = chr n
digit c = isDigit c
e :: (Floating a) => a
e = exp 1
entier x = floor x
filemode f = error "Miranda.filemode"
--getenv
hd xs = head xs
hugenum :: (Floating a) => a
hugenum = error "hugenum" --!!!
integer x = x == truncate x
letter c = isAlpha c
map2 f xs ys = zipWith f xs ys
--max
max2 x y = max x y
member xs x = x `elem` xs
--min
min2 x y = min x y
mkset xs = nub xs
neg x = negate x
numval :: (Num a) => String -> a
numval cs = read cs
postfix xs x = xs ++ [x]
--read
scan f z l = scanl f z l
--shownum !!!
--showfloat !!!
--showscaled !!!
tinynum :: (Floating a) => a
tinynum = error "tinynum"
undef = error "undefined"
zip2 xs ys = zip xs ys
--zip
|