I'm playing around with GHCi for the first time, and I'm having some trouble writing multi-line functions.
My code is as follows:
Prelude> :{
Prelude| let diffSquares lst = abs $ squareOfSums lst - sumOfSquares lst
Prelude| where
Prelude| squareOfSums lst = (fst (sumsAndSquares lst))^2
Prelude| sumOfSquares lst = snd (sumsAndSquares lst)
Prelude| sumsAndSquares = foldl ((sms,sqrs) x -> (sms+x,sqrs+x^2)) (0,0)
Prelude| :}
It gives the following error:
<interactive>:1:142: parse error on input `='
Could someone kindly point me in the direction of what I'm missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…