Brent Yorgey wrote:
>
> On 8/29/07, Alexteslin <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hello,
>>
>> I just came across with this question on the exam and can not think of
>> implementing it.
>
>
> Wait, is this an exam for a class you
Alexteslin wrote:
>
> Hello,
>
> I just came across with this question on the exam and can not think of
> implementing it.
>
> mapPair :: (a -> a -> a) -> [a] -> [a]
>
> such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
>
> and i
Hello,
I just came across with this question on the exam and can not think of
implementing it.
mapPair :: (a -> a -> a) -> [a] -> [a]
such that mapPairs f [x1, x2, x3, x4...] = [f x1 x2, f x3 x4,...]
and if the list contains an odd number of elements, the last one is kept
unchanged, for exampl
Aaron Denney wrote:
>
> (Quoting reformatted. Try to have your responses below what you are
> responding to. It makes it easier to read as a conversation.)
>
> On 2007-08-14, Alexteslin <[EMAIL PROTECTED]> wrote:
>> Aaron Denney wrote:
>>> Folds repl
Well, i have tried cons (:) operator but when it passed to foldr doesn't work
because cons operator operates first character and then the list but the
foldr argument takes a function (a->a->a). Maybe i am missing the point
here?
Aaron Denney wrote:
>
> On 2007-08-14, A
Hi,
I am trying to do the exercise which asks to define built-in functions
'last' and 'init' using 'foldr' function, such as last "Greggery Peccary" =
'y'
the type for my function is:
myLast :: [Char] -> Char
I am not generalizing type so that make it less complicated. But what ever
i am tr
Alexteslin wrote:
>
> Hi, I am doing some simple exercises about recursive algebraic types and
> this particular exercise asks to define a function which counts the number
> of operators in an expression. I defined the function below, but i am not
> sure if on the second lin
Hi, I am doing some simple exercises about recursive algebraic types and this
particular exercise asks to define a function which counts the number of
operators in an expression. I defined the function below, but i am not sure
if on the second line changing from "evalLength (Lit n) = n" to "(Lit
Thank you guys, i didn't understand the concept of the chapter.
Brent Yorgey wrote:
>
> On 7/25/07, Alexteslin <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi,
>>
>> I am going through examples from the textbook and trying them out but
>> some
>&
Hi,
I am going through examples from the textbook and trying them out but some
don't work.
For example:
addNum :: Int -> (Int -> Int)
addNum n = addN
where
addN m = n+m
This error message i am getting:
ERROR - Cannot find "show" function for:
*** Expression : addNum 4
*** Of ty
that f never changes if it is defined in only one spot.
>
> Later, when you study monads you will notice the same pattern in the
> Reader monad, where the technique is even more valuable.
>
> Dan Weston
>
> Alexteslin wrote:
>>
>> filterAlpha :: (a -> B
apfelmus wrote:
>
> Alexteslin wrote:
>> filterAlpha :: (a -> Bool) -> [a] -> [a]
>> filterAlpha f [] = []
>> filterAlpha f (x:xs)
>> |f x= x : filterAlpha xs
>> |otherwise = filterAlpha xs
>>
>>
>> and i
Hi,
first I like to thank all of you guys - it really helps!
I am still on a same chapter with higher order functions and this function
is also confusing.
But before i even define this function i am getting the type error - i don't
know why? So i wrote the simpler one like:
filterAlpha :: (a ->
What wrong with my original solution?
allEqual2 :: [Int] -> Bool
allEqual2 xs = length xs == length (filter isEqual xs)
where
isEqual n = (head xs) == n
It looks simpler to me
Dan Weston wrote:
>
> The real lesson here is that
>
> 1) no problem is "too easy" to cheat good sof
tually-exclusive patterns are listed, so
> I find it clearer to put the base case of an induction first, so I don't
> forget it.
>
> Dan
>
> Alexteslin wrote:
>> I have defined the first line it seems right to me but second line not
>> sure.
>> I have Tr
I have defined the first line it seems right to me but second line not sure.
I have True or False and whatever value i give it produces that value.
allEqual :: [Int] -> Bool
allEqual (x1:x2:xs) = (x1 == x2) && allEqual xs
allEqual _ = ???
Steve Schafer wrote:
>
> On Thu, 19 Jul 2007
obably they are not interested ones
but I am just trying to learn the thinking behind the function definitions.
Thank you
Joachim Breitner-2 wrote:
>
> Hi,
>
> Am Mittwoch, den 18.07.2007, 13:42 -0700 schrieb Alexteslin:
>> I am trying to define a function as part of the exe
Hello,
I am trying to define a function as part of the exercises that gives a
result of a minimum value of the input list of ints. Such as this:
minimumValue :: [Int] -> Int
minimumValue ns ...
using either filter or map functions but Not foldr1, because the exercise
precedes the section on fol
Oh, I am lost now - for now anyway.
I am attempting to do next exercise in the book to define reverse function
using primitive recursion and pattern matching on lists. But getting stack
because when i con in front of xs (xs:x) i get en error, which i thought i
would be getting anyway. I tried
quot;input list" is really [1,4,5,3] but you
> can get this with head and tail). I'm just learning about the fold family
> myself. - Greg
>
> Prelude> foldl (\a b -> if (any (\x -> x == b) a) then a else b:a) [1]
> [4,5,3,3,4]
> [3,5,4,1]
>
>
>
&
|x == y = deleteElem x ys
|otherwise = y:deleteElem x ys
And I did think about for every call it will go through an entire list - now
i know where the solution lies.
Thanks again
Dan Weston wrote:
>
> Alexteslin wrote:
> > I'v got it - it produces the right output.
> >
ut how to implement the deleteElt function.
>
> hope this is helpful!
> -Brent
>
> On 7/10/07, Alexteslin <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi, i am a beginner to Haskell and i have a beginner's question to ask.
>>
>> An exercise asks t
Hi, i am a beginner to Haskell and i have a beginner's question to ask.
An exercise asks to define function unique :: [Int] -> [Int], which outputs
a list with only elements that are unique to the input list (that appears no
more than once). I defined a function with list comprehension which wor
23 matches
Mail list logo