haskell - Recursive function of a list -


i'm little confused recursive function on haskell, can explain me better ?

cut [] = ([],[]) cut (x:[]) = ([x],[])  cut (x:y:l) = let (xs,ys) = cut l              in (x:xs,y:ys) 

p.s. : "let...in" part confusing me lot !

haskell let has following syntax: let <bindings> in <expression>

so create bindings , use in expression.

example:

λ> let = 3 in + 3 6 

the type of cut function cut :: [a] -> ([a], [a]).

so, function cut returns tuple of type ([a],[a]) , pattern matched in let expression of cut function. variable xs pattern matched first element of tuple i.e [a] , next variable ys pattern matched second element of tuple list.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -