combinators Questions

3

Solved

iterate :: (a -> a) -> a -> [a] (As you probably know) iterate is a function that takes a function and starting value. Then it applies the function to the starting value, then it applies...
Grille asked 22/9, 2010 at 13:34

4

Solved

Can an analog of the S combinator be expressed in Haskell using only standard functions (without defining it by equation) and without using lambda (anonymous function)? I expect it to by of type (a...
Sinaloa asked 15/4, 2014 at 21:52

3

Solved

I am finding it hard to find examples of on in Haskell and I don't understand the explanation on Hoogle's Data.Function page. Please, can I have examples of its use and examples of problems/code wh...
Selfassurance asked 7/12, 2023 at 16:55

6

Solved

I'm going through a phase of trying to avoid temporary variables and over-use of conditional where I can use a more fluid style of coding. I've taken a great liking to using #tap in places where I ...
Upsweep asked 24/10, 2011 at 16:21

4

Solved

This is a implementation of the Y-combinator in Scala: scala> def Y[T](func: (T => T) => (T => T)): (T => T) = func(Y(func))(_:T) Y: [T](func: (T => T) => (T => T))T => ...
Waterfall asked 13/1, 2016 at 19:43

5

The K-combinator can be implemented as below and the implementation should not have any side-effects. const K = x => y => x; It is sometimes called "const" (as in Haskell). The K function ...
Catto asked 28/7, 2016 at 11:54

6

Solved

I've looked at different folds and folding in general as well as a few others and they explain it fairly well. I'm still having trouble on how a lambda would work in this case. foldr (\y ys -&gt...
Anzovin asked 16/10, 2010 at 19:53

11

Solved

Can anybody explain how does foldr work? Take these examples: Prelude> foldr (-) 54 [10, 11] 53 Prelude> foldr (\x y -> (x+y)/2) 54 [12, 4, 10, 6] 12.0 I am confused about these execut...
Livraison asked 18/11, 2009 at 17:36

4

Solved

A quick question that has been bugging me lately. Does Haskell perform all the equivalence test in a function that returns a boolean, even if one returns a false value? For example f a b = ((a+b...
Mccurdy asked 22/11, 2009 at 14:52

1

Solved

I've been following a Rust tutorial where two versions of a function are purported to generate the same results: Version 1: pub fn get_transactions(fname:&str) -> Result<Vec<Transactio...
Gangplank asked 11/8, 2020 at 13:10

4

Solved

Note 1 : Here CPS stands for "continuation passing style" I would be very interested in understanding how to hook into C# async machinery. Basically as I understand C# async/await feature, the com...

4

Solved

I'm trying to figure out the behavior of the library function groupBy (from Data.List), which purports to group elements of a list by an "equality test" function passed in as the first argument. Th...
Timber asked 22/8, 2009 at 16:27

18

Solved

A Y-combinator is a computer science concept from the “functional” side of things. Most programmers don't know much at all about combinators, if they've even heard about them. W...

7

Solved

I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around implementing foldl in terms of foldr. (Here's their code:) myFoldl :: (a -> b -> a) -> a -> [b]...
Diploid asked 24/10, 2008 at 20:27

3

Solved

Much of what makes haskell really nice to use in my opinion are combinators such as (.), flip, $ <*> and etc. It feels almost like I can create new syntax when I need to. Some time ago I wa...
Novokuznetsk asked 23/11, 2011 at 19:49

2

Solved

I'm playing around with existentials and GADTs in Haskell, and I'm trying to define a DSL for combinators (such as SKI). I have the GADT working, as well as a reduction function which works fine (a...
Dalmatia asked 25/6, 2016 at 2:47

1

Solved

I'm a beginner in haskell, and trying to implement the Church encoding for natural numbers, as explained in this guide. I used a definition of y combinator from this answer, but not sure how to app...
Nicaea asked 24/4, 2016 at 17:30

2

Solved

In Edward Kmett's talk Lenses, Folds, and Traversals, on the slide "The Power is in the Dot", he shows the type of (.) . (.) . (.) is (a -> b) -> (c -> d -> e -> a) -> c -> d...

5

Solved

In Haskell I would write: main = do mapM_ print . map (\x -> x^2) . filter (\x -> (mod x 2) == 0) $ [1..20] in Python I would have to use either many brackets or useless variables ... is t...
Prophet asked 28/10, 2015 at 13:4

1

Solved

In Haskell, we have Data.Function.on: on :: (b -> b -> c) -> (a -> b) -> a -> a -> c (.*.) `on` f = \x y -> f x .*. f y In Clojure, I want to be able to define, for examp...
Septuagesima asked 31/7, 2015 at 2:16

7

Solved

I just wrote the following two functions: fand :: (a -> Bool) -> (a -> Bool) -> a -> Bool fand f1 f2 x = (f1 x) && (f2 x) f_or :: (a -> Bool) -> (a -> Bool) -> ...
Volley asked 18/4, 2011 at 23:45

2

Solved

Given, for example, the following tree data type: data Tree a = Node [Tree a] | Leaf a deriving Show type Sexp = Tree String How do I express a "pretty" function using an high-order combinator, ...
Math asked 16/2, 2015 at 1:16

2

Solved

Fixed-point combinators provide a way for anonymous functions to refer to themselves or to build mutually recursive structures. Although useful in lambda-calculus, they are essentially superfluous ...
Horseleech asked 5/11, 2014 at 16:53

1

Solved

I have been taking up F# recently (my background is C#) and am reading the site http://fsharpforfunandprofit.com, which I am finding very helpful. I've got to http://fsharpforfunandprofit.com/pos...

1

Solved

I want to write a Haskell function that returns a list appended to itself count times (like lst * count in Python). My first attempt is: self_append_n :: Int -> [a] -> [a] self_append_n = c...

© 2022 - 2025 — McMap. All rights reserved.