Tagged Questions
0
votes
2answers
154 views
Haskell Applying 2 lambda expressions to list of tuples
I'm struggling to understand lambda expressions in Haskell.
He is the problem:
I have a list of tuples [(a,b),(c,d),(e,f)...] (it can be of any length)
I want to apply two functions f1 and f2 to ...
2
votes
3answers
157 views
Haskell - What does the lambda in this primality test mean and how does this work?
From http://www.haskell.org/haskellwiki/Testing_primality, there is this code:
isPrime n = n > 1 &&
foldr (\p r -> p*p > n || ((n `rem` p) /= 0 && r)) True primes
Where ...
1
vote
2answers
451 views
Haskell - Lambda calculus equivalent syntax?
While writing some lambda functions in Haskell, I was originally writing the functions like:
tru = \t f -> t
fls = \t f -> f
However, I soon noticed from the examples online that such ...
0
votes
2answers
217 views
json parsing in haskell part 2 - Non-exhaustive patterns in lambda
This is actually in continuation of the question I asked a few days back. I took the applicative functors route and made my own instances.
I need to parse a huge number of json statements all in a ...
0
votes
1answer
84 views
Haskell component-by-component addition
I am trying do to the component-by-component addition of a list of tuples with the use of higher functions. The result should be the (sum of the first component, sum on the second component).
...
0
votes
2answers
69 views
foldr confusion
I execute this statement on the interpreter
foldr (\x (a, b) -> if x == '_' then (a+1, [((div a 3), (mod a 3))] ++ b) else (a, b)) (0, []) "_______OX"
I expected the output to be
...
0
votes
1answer
197 views
Finding out lambda calculus/haskell type of some example
Suppose that the function gets as its input two variables of different types (e.g. one variable is int in the language of C, and one variable is char in the language of C) and returns one variable ...
1
vote
3answers
133 views
writing a recursive function using foldr
I am new in Haskell programming.
While practicing I was asked to make a recursive function that looks like this:
repeat1 5 [1,2,3] = [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]]
which is
repeat1 ...
0
votes
1answer
278 views
No instance for (Show ([(String, Int)] -> Int))
to calculate the value of the expression on the fly at the production rules in happy doesn't work if I'm using the lambda expressions.
For example this code
Exp : let var '=' Exp in Exp { \p ...
6
votes
2answers
395 views
Haskell Lambda functions — two seemingly equivalent functions, one works and the other is erroneous
This Lambda function returns 1:
(\x y -> 1) 1 p
where p = (\x y -> 1)
Okay, that makes sense to me -- the Lambda function returns 1, independent of its arguments.
Now, this Lambda function ...
6
votes
5answers
674 views
Haskell: where clause referencing bound variables in lambda
I am trying to numerically integrate a function in Haskell using the trapezoidal rule, returning an anti-derivative which takes arguments a, b, for the endpoints of the interval to be integrated.
...
2
votes
1answer
278 views
applying a list to an entered function to check for tautology
I want to write a function in haskell which determines whether a boolean function (entered with a lambda-expression in ghci) is a tautology or not.
The input should look like this:
taut n (\[x..] ...
1
vote
5answers
376 views
Practice part of lambda abstractions
I'm new in Haskell programming. Now i'm learn lambda function and lambda abstractions. And i thought, what's the practice part of lambda functions. For example we have:
map(\x -> x * 2) ...