types - Defining a datatype in Haskell -
greetings, new haskell , i've gotten stuck in defining datatype assignment.
i need create "strategy" type, it's string 1-6 characters each representing numeric value, , must represent values greater 9 letter (up 35 total different values), tried defining auxiliary type representing each possible value , using create type, code isn't working , have ran out of ideas. definition have been trying:
data value = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'i' |'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' |'r' | 's' | 't' | 'u' | 'v' | 'w' | 'y' | 'x' | 'z' data strategy = value | value:value | value:value:value | value:value:value:value | value:value:value:value:value | value:value:value:value:value:value
the value type isn't accepting numbers, , strategy type "sort of" works second constructor after goes bust. help!
just previous (deleted) question, looks lot homework. helps if pick real name , not use throw-away account.
this page tells how use haskell's data
type declarations. doing different/wrong?
you use characters instead of constructors
value
.'1'
'2'
, etc characters, need constructor along 0 or more fieldsvaluecon1 char
,valuecon2 string
you using list constructors , assume field of
value
instead of defining new constructorsstrategy
. perhaps wantdata strategy = strat [value]
, accept list of size. while more painful can define many many strategy constructors finite number of separatevalue
fields.
btw - course taught? seems late in term covering these basics.
Comments
Post a Comment