문제

Question

I have defined a user defined type as

type asd = [(Char,Int)]

How can i assigin a value to a type asd such as asd= [("Hello",1)] (Not in run time) to keep hard code a value in source code

is this possible ? , becouse there is no variable concept in functional programming

도움이 되었습니까?

해결책

You are defining a constant. An example would be:

-- A type of lists of pairs
type ASD = [(String,Int)]

-- A value of type ASD
asd :: ASD
asd = [("Hello", 1)]

That is, you just declare what the value of asd is.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top