[Haskell-cafe] Why cannot i add the `let` declaration ?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat Jan 30 03:31:25 EST 2010


zaxis <z_axis at 163.com> writes:
> find_the_day sDay 0 = sDay
> find_the_day sDay nDay = 
>     let nextDay = addDays 1 sDay
>     if (is_trade_day $ nextDay)
>     then find_the_day nextDay (nDay - 1)
>     else find_the_day nextDay nDay

The correct syntax is let ... in ...; you've forgotten the "in", so
something like this:

,----
| find_the_day sDay 0 = sDay
| find_the_day sDay nDay = 
|     let nextDay = addDays 1 sDay
|     in if (is_trade_day $ nextDay)
|        then find_the_day nextDay (nDay - 1)
|        else find_the_day nextDay nDay
`----

Note that in do-blocks you don't need the `in'; in "normal" code you do.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list