[Haskell-cafe] General Advice Needed ..

Gregory Crosswhite gcross at phys.washington.edu
Thu Jan 14 12:44:58 EST 2010


Yes.  An approach that I have always used that has worked well for me is to keep a list of "tricks" while I am studying.  Whenever I get stuck on a practice problem but eventually figure it out (either by simply thinking harder, looking it up, or asking someone for help), I try to identify the missing link that had prevented me from seeing how to do it immediately, and then write it down on my "tricks" list so that I know that I need to keep that trick in mind while I am taking the test.

Cheers,
Greg


On Jan 14, 2010, at 8:53 AM, Ian675 wrote:

> 
> thankyou.. that made more sense to me :)
> 
> What im doing now is.. 
> Im still working through the "Craft of Functional Programming" book but I've
> found a site that has solutions to some of the excercise questions. So i'm
> noting them down and trying to make sense of them
> 
> Is that a good approach?
> 
> 
> Henk-Jan van Tuyl wrote:
>> 
>> On Thu, 14 Jan 2010 15:38:26 +0100, Ian675 <adam_khan_rfc at hotmail.com>  
>> wrote:
>> 
>>> 
>>> Pretty much yeah.. Im going through the book and things like :
>>> 
>>> Define a function rangeProduct which when given natural numbers m and n,
>>> returns the product m*(m+1)*....*(n-1)*n
>>> 
>>> I got the solution from my lecture notes but I still dont understand it..
>>> 
>>> rangeProduct :: Int -> Int -> Int
>>> rangeProduct m n
>>>                  | m > n = 0
>>>                  | m == n = m
>>>                  | otherwise = m * rangeProduct (m+1) n
>>> 
>> 
>> I'll try to give a clear explanation of this function:
>> 
>>> rangeProduct :: Int -> Int -> Int
>>> rangeProduct m n
>> A function is defined with parameters m and n, both Int; the result of the  
>> function is also an Int
>> 
>>>                  | m > n = 0
>> If m > n, the result is 0; the rest of the function definition will be  
>> skipped
>> 
>>>                  | m == n = m
>> If m is not larger then n, evalution continues here; if m == n, the result  
>> of the function is m
>> 
>> 
>>>                  | otherwise = m * rangeProduct (m+1) n
>> If previous predicates were False, this branch is evaluated ("otherwise"  
>> is always True); the function calls itself with (m+1) as first parameter
>> 
>> The boolean expressions in this function are called "guards"; the right  
>> hand side after the first guard that evaluates to True, will give the  
>> result of the function.
>> 
>> Regards,
>> Henk-Jan van Tuyl
>> 
>> 
>> --
>> http://Van.Tuyl.eu/
>> http://members.chello.nl/hjgtuyl/tourdemonad.html
>> --
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> 
>> 
> 
> -- 
> View this message in context: http://old.nabble.com/General-Advice-Needed-..-tp27161410p27164433.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list