[Hugs-users] School assignment help

Neil Mitchell ndmitchell at gmail.com
Wed Oct 24 16:47:25 EDT 2007


Hi

This is the place for questions specifically about the Hugs system -
for general Haskell help you will get a much larger audience on
haskell-cafe -AT- haskell.org - I suggest reposting this email to
there.

There is a page about how to ask for homework help on the Haskell
wiki: http://haskell.org/haskellwiki/Homework_help

Thanks

Neil

On 10/24/07, Urmastaag <urmastaag at hotmail.com> wrote:
>
> Hello!
>
> Can anybody point me to a right way here?
> I have those exercises in haskell that i cannot do, because haskell is so
> much different from other languages that i use. I have read so much from
> different manuals but i do not understand haskell enough yet.
>
> First exercise:
>
> I must find a shorter list.
> Here's how i did that, but my teacher said that it is unefficient way to do
> it.
>
> getShorter :: [a] -> [a] -> [a]
> getShorter xs ys | length xs <= length ys = xs
>                        | otherwise                  = ys
>
> How do i do it effective, so that i only check as many elements from lists
> as many are in the shortest list?
>
> Second exercise:
>
> Second exercise also need an effective answer:
>
> I have to remove any occurances of certain number from list and give the
> number of how many times that number was removed.
>
> Unefficient version:
> remCount :: Int -> [Int] -> (Int,[Int])
> remCount n xs = (length xs - length ys, ys)
>        where ys = [ x | x <- xs, x /= n]
>
>
>
> Exercise three:
>
> moneyBack :: Int -> [(Int,Int)]
>
> I must print out all pairs of bank notes and (bank notes, how many) which
> salesman would give me back when he/she has to give me like 456 back.
>
> moneyBack 0        ==>   []
> moneyBack 10      ==>   [(10,1)]
> moneyBack 123     ==>   [(100,1),(10,2),(2,1),(1,1)]
> moneyBack 5326   ==>   [(500,10),(100,3),(25,1),(1,1)]
>
> If anybody could point me in a right direction that would be great.
> Haskell seems very cool because the code is usually really short, but i just
> need a start. I need more examples than i can find from google (maybe i'm
> not using the right keywords).
>
> Thanks.
>
> --
> View this message in context: http://www.nabble.com/School-assignment-help-tf4685176.html#a13388655
> Sent from the Haskell - Hugs-Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Hugs-Users mailing list
> Hugs-Users at haskell.org
> http://www.haskell.org/mailman/listinfo/hugs-users
>


More information about the Hugs-Users mailing list