On Tue, Sep 25, 2007 at 10:53:55AM +0100, Andrew Coppin wrote:
> Tristan Allwood wrote:
>>
>> Just to follow those sentiments, the version I knocked out quickly
>> looked like:
>> (It's not quite the same as the original function, I think I'm lacking a
>> map (map (take 8)) on the first line).
>>
>> showSystems :: Show a => [[a]] -> String
>> showSystems = unlines . zipWith showSystem [1..]   
>>   where
>>     showSystem n as = "Eq" ++ (show n) ++ ": " ++ sum ++ " = " ++ val
>>       where
>>         sum = concat . intersperse " + " . zipWith showNum [1..] $ (init 
>> as)
>>         val = show . last $ as
>>         showNum n a = show a ++ " x" ++ show n
>>
>>   
>
> I'm puzzled - do we have 2 seperate where clauses?

Yes there are 2 and no they arn't seperate.  The second where clause is
nested and is a set of definitioins local to showSystem, and as such can
use the bound values of n and as. (But it can also "see" any values
bound by showSystems and its where clause (which in this case is just
the definition of showSystem).

Clear as mud?

T
-- 
Tristan Allwood
PhD Student
Department of Computing
Imperial College London
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to