diff options
Diffstat (limited to 'pascal.icl')
| -rw-r--r-- | pascal.icl | 52 |
1 files changed, 51 insertions, 1 deletions
@@ -16,7 +16,57 @@ Run the program using the "Basic Values Only" option (Application options). Use a non-proportional font for the output (e.g. Monaco 9). */ -import StdEnv +import _SystemArray + +(+) infixl 6 :: !Int !Int -> Int +(+) a b = code inline { + addI +} + +(-) infixl 6 :: !Int !Int -> Int +(-) a b = code inline { + subI +} + +(/) infixl 7 :: !Int !Int -> Int +(/) a b = code inline { + divI +} + +inc :: !Int -> Int +inc a = a + 1 + +take :: Int [a] -> [a] +take 0 _ = [] +take n [x:xs] = [x:take (n-1) xs] + +(+++) infixr 5 :: !{#Char} !{#Char} -> {#Char} +(+++) a b = code inline { + .d 2 0 + jsr catAC + .o 1 0 +} + +repeat :: a -> [a] +repeat x = cons +where cons = [x:cons] + +repeatn :: !.Int a -> [a] +repeatn n x = take n (repeat x) + +spaces :: !.Int -> [Char] +spaces n = repeatn n ' ' + +class toString a :: a -> String + +instance toString [Char] where toString a = {c \\ c <- a} +instance toString Int where toString a = code inline { + .d 0 1 i + jsr ItoAC + .o 1 0 +} + +//import StdEnv /* A row of the triangle is represented by a list of integers, the triangle as a list of rows: |
