1 module Stdlib 2 3 4 5 6 7 8 ( mapcat,map2,mappair,seQuence, 9 middle,mkset,between,pair,--UNUSED: pairUp,curry, 10 {-const,-}const3,splitAt_YORK,numval,toNum,all_YORK) 11 12 where 13 14 15 16 mapcat :: (a->[b]) -> [a] -> [b] 17 mapcat f x = foldr (++) [] (map f x) 18 19 20 21 22 map2 :: (a->b->c) -> [a] -> [b] -> [c] 23 map2 _ [] l = [] 24 map2 _ l [] = [] 25 map2 f (x:xs) (y:ys) = (f x y):(map2 f xs ys) 26 27 28 29 mkset [] = [] 30 mkset (a:l) = a:mkset ((filter ((/=) a)) l) -- "remove" no longer in prelude 31 32 33 34 mappair :: (a->b) -> (a,a) -> (b,b) 35 mappair f (a,b) = (f a,f b) 36 37 38 39 40 middle :: Int-> Int-> Int 41 middle x y = div (x+y) 2 42 43 44 45 46 47 between :: (Ord a,Num a) => a -> a -> a -> Bool 48 between base offset value = (base <= value) && (value <= (base+offset)) 49 50 51 52 53 pair :: a -> b -> (a,b) 54 pair x y = (x,y) 55 56 57 58 59 {- 60 const :: a -> b -> a 61 const x y = x 62 -} 63 64 65 66 const3 :: a -> b -> c -> d -> a 67 const3 w x y z = w 68 69 70 71 72 73 splitAt_YORK ::(Eq a) => a -> [a] -> ([a],[a]) 74 splitAt_YORK ch [] = ([],[]) 75 splitAt_YORK ch (a:l) | a==ch = ([], l) 76 splitAt_YORK ch (a:l) | otherwise = (a:x,y) 77 where (x,y) = splitAt_YORK ch l 78 79 80 81 82 numval :: String -> Int 83 numval x = numval' (length x-1) x 84 where numval' _ [] = 0 85 numval' x (a:l) = (toNum a)*(10^x) + (numval' (x-1) l) 86 87 88 89 90 91 toNum :: Char -> Int 92 toNum x = (fromEnum x - fromEnum '0') 93 94 95 96 97 seQuence :: [String] -> String 98 seQuence = concat 99 100 101 102 103 all_YORK :: [Bool] -> Bool 104 all_YORK = and