I am having trouble understanding the full scope of the 'in' keyword in haskell. It was my understanding that you could use it to pass arguments to a function. However, I am having trouble understanding how the applies to a function similar to that shown below:
foo xs a =
case xs of
[] -> (a,[])
y:ys ->
let (n,ns)=foo ys a in
if y>0 then (1+n,y:ns)
else (n,ns)
How does 'in' apply to the equation if it is supplying parameters that foo does not take?
in
is not a standalone keyword; it is always accompanied bylet
:let {- definitions -} in {- expression that uses the definitions -}
. (2) In your case, the let-expression definesn
andns
, in terms offoo
,ys
anda
. – duplode