Appendix A.

Source code for stir.hs

Here is the source code for the stir.hs:
-- Time-stamp: >Tue Apr 25 2000 21:49:53 Stardate: [-30]4714.33 hwloidl<
--
-- A fibish parallel test program computing Stirling numbers.
-- Uses Haskell 1.4
-----------------------------------------------------------------------------

module Main(main) where

import Parallel
import System     (getArgs)

-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

args_to_IntList :: [String] -> [Int]
args_to_IntList a = if length a < 2
		      then error "Usage: stir n k \n"
		      else map read a

fact :: Int -> Int
fact 0 = 1
fact n = n * fact (n-1)

-- Binominal coefficient
bin :: Int -> Int -> Int
bin n k | k>n = 0
        | otherwise = fact n `div` (fact k) * (fact (n-k))

-- Stirling numbers
stir1, stir2 :: Int -> Int -> Int
stir1 n k | n==k = 1
          | n==0 = 0
          | k>n = 0
          | otherwise = x `par` y `par` (n-1) * x + y
                        where x = stir1 (n-1) k
		              y = stir1 (n-1) (k-1)
stir2 n k | n==k = 1
          | n==0 = 0
          | k>n = 0
          | otherwise = x `par` y `par` k * x + y
                        where x = stir2 (n-1) k
                              y = stir2 (n-1) (k-1)

main = getArgs >>= \ a ->
       let
         l = args_to_IntList a
	 n = l!!0
         k = l!!1
         res = stir1 n k 
       in
        putStr ("stir1 " ++ (show n) ++ " " ++ (show k) ++ " = " ++ 
                (show res) ++ "\n")