All pastes #775027 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-15 13:36 UTC
rendered paste body
module Third where

-- football pools exercise
-- results given originally as a list of Strings
-- each result starts with the match No.
type RStrings = [String]
rslis :: RStrings
rslis = ["1 West_Brom 1 1 Fulham",
         "2 Crystal_Palace 1 2 Man_City",
         "3 Norwich 0 0 Aston_Villa",
         "4 Blackburn 1  0 Portsmouth",
         "5 Birmingham 1  1 Charlton",
         "6 Arsenal 2  2 Bolton",
         "7 Sunderland 3  1 Preston",
         "8 Brighton 2  3 QPR",
         "9 Leicester_City 0  0 Burnley",
         "10 Wigan_Athletic 4  0 Sheff_Utd",
         "11 Stoke_City 0  0 Nottm_Forest",
         "12 Cardiff_City 0  2 Derby_County",
         "13 Reading 3  1 Gillingham",
         "14 Crewe 2  2 Leeds_United", 
         "15 Coventry_City 0  0 Rotherham_Utd",
         "16 Plymouth 1  2 Wolves",
         "17 West_Ham_Utd 1  1 Ipswich_Town",
         "18 Blackpool 1  1 Swindon_Town",
         "19 Bradford_City 4  1 Bristol_City",
         "20 Hartlepool 4  1 Torquay_United",
         "21 Huddersfield 0  2 Barnsley",
         "22 Stockport 1  3 Luton_Town",
         "23 Doncaster 1  1 Oldham",
         "24 Brentford 1  0 Port_Vale",
         "25 Sheff_Wed 0  1 Bournemouth", 
         "26 Chesterfield 1  0 Walsall",
         "27 Colchester 0  1 Milton_Keynes",
         "28 Peterborough 2  3 Hull_City", 
         "29 Tranmere 1  1 Wrexham", 
         "30 Notts_County 1  2 Southend_Utd",
         "31 Boston_United 2  2 Shrewsbury",
         "32 Rushden 1  0 Cheltenham",
         "33 Bury 0  1 Scunthorpe_Utd",
         "34 Grimsby_Town 2  0 Leyton_Orient",
         "35 Bristol_Rovers 0  0 Lincoln_City",
         "36 Wycombe 0  1 Swansea_City",
         "37 Mansfield_Town 1  0 Rochdale",
         "38 Yeovil 6  1 Oxford_Utd",
         "39 Kidderminster 1  0 Macclesfield",
         "40 Darlington 1  1 Northampton",
         "41 Chester 0  0 Cambridge_Utd"]

type Results = [(Int,String,Int,Int,String)]

RStrings2Results :: RStrings -> Results
RStrings2Results rs = map (
	let l = words
	in (l!!1,l!!2,l!!3,l!!4,l!!5)
	) rs