1 -- Glasgow Haskell 0.403 : FINITE ELEMENT PROGRAM 2 -- ********************************************************************** 3 -- * * 4 -- * FILE NAME : basics.hs DATE : 4-3-1991 * 5 -- * * 6 -- * CONTENTS : Basics functions for output. * 7 -- * * 8 -- ********************************************************************** 9 10 11 module Basics(showrj,showlj, azip, module Array) where 12 13 import Array 14 15 16 showlj, showrj :: (Show a) => Int -> a -> [Char] 17 18 rep :: Int -> a -> [a] 19 20 rep 0 x = [] 21 rep n x = x : (rep (n-1) x) 22 23 showrj l x 24 = (rep bs ' ') ++ ns 25 where 26 ns = dropWhile ((==) ' ') (show x) 27 bs | l <= length ns = 1 28 | otherwise = l - length ns 29 30 showlj l x 31 = ns ++ (rep bs ' ') 32 where 33 ns = dropWhile ((==) ' ') (show x) 34 bs | l <= length ns = 1 35 | otherwise = l - length ns 36 37 azip :: [a] -> [b] -> [(a,b)] 38 39 azip [] [] = [] 40 azip ( x : ls ) ( x' : ls' ) = (x,x') : (azip ls ls') 41 42