y-combinator Questions

2

Solved

I couldn't understand the Y-combinator, so I tried to implement a function that enabled recursion without native implementation. After some thinking, I ended up with this: Y = λx.(λv.(x x) v) Wh...

1

Solved

;; compute the max of a list of integers (define Y (lambda (w) ((lambda (f) (f f)) (lambda (f) (w (lambda (x) ((f f) x))))))) ((Y (lambda (max) (lambda (l) (cond ((null? l) -1) ((> (...
Arkose asked 28/10, 2012 at 22:9

2

Solved

Agda manual on Inductive Data Types and Pattern Matching states: To ensure normalisation, inductive occurrences must appear in strictly positive positions. For instance, the following datatype i...

1

Solved

I've spent a day reading page 166's length≤1 in the book The Little Schemer; there's the following code: (((lambda (mk-length) (mk-length mk-length)) (lambda (mk-length) (lambda (l) (cond ((n...

3

Solved

I'm interested in actual examples of using fixed point combinators (such as the y-combinator in C++. Have you ever used a fixed point combinator with egg or bind in real live code? I found this ex...
Alamo asked 30/9, 2008 at 7:29

1

Here's the code (also here): #lang racket (define poorY ((lambda length (lambda (ls) (cond [(null? ls) 0] [else (add1 ((length length) (cdr ls)))]))) (lambda length (lambda (ls) (cond [(n...

2

Solved

So, I've spent a lot of time reading and re-reading the ending of chapter 9 in The Little Schemer, where the applicative Y combinator is developed for the length function. I think my confusion boil...
Pontoon asked 8/5, 2012 at 13:24

3

Solved

The Wikipedia article on the Y combinator provides the following JavaScript implementation of the Y combinator: function Y(f) { return ( (function (x) { return f(function (v) { return x(x)(v); ...
Godchild asked 14/6, 2012 at 11:51

1

Solved

I'm trying to use the y-combinator to define gcd in scala: object Main { def y[A,B]( f : (A => B) => A => B ) : A => B = f(y(f)) def gcd = y[(Int,Int),Int]( (g) => (x,y) => if ...
Gaullist asked 20/1, 2012 at 23:26

4

Solved

Why is the type of this function (a -> a) -> a? Prelude> let y f = f (y f) Prelude> :t y y :: (t -> t) -> t Shouldn't it be an infinite/recursive type? I was going to try and put int...
Pizzeria asked 18/1, 2012 at 23:20

4

Solved

I have a recursive function (in C#) that I need to call about 800 million times; this would obviously normally result in a stack overflow after about the 900th call. I've kicked this out to multipl...
Gerrygerrymander asked 2/12, 2011 at 7:10

3

Solved

I was trying to solve the maximal subsequence sum problem and came up with a neato solution msss :: (Ord a, Num a) => [a] -> a msss = f 0 0 f gmax _ [] = gmax f gmax lmax (x:xs) = let g =...

1

Solved

My brain seems to be in masochistic mode, so after being drowned in this, this and this, it wanted to mess around with some DIY in C#. I came up with the following, which I don't think is the Y-co...
Subminiature asked 5/10, 2011 at 9:11

1

Solved

I was fiddling with combinators in JavaScript and was being proud of (hopefully) getting S to work when I stumbled upon Wikipedia saying: "The Y combinator can be expressed in the SKI-calculus...

4

Solved

I'm trying to learn the Y-combinator better (I sort of understand it in Scheme) and implement it in D 2.0, and I'm failing pretty miserably: auto fact = delegate(uint delegate(uint) recurse) { re...
Tidewater asked 4/8, 2011 at 7:44

2

Solved

In order to learn what a fixed-point combinator is and is used for, I wrote my own. But instead of writing it with strictly anonymous functions, like Wikipedia's example, I just used define: (defi...
Klemm asked 14/1, 2011 at 1:28

5

Solved

I surfed into this site a few days ago on "Anonymous Recursion in C#". The thrust of the article is that the following code will not work in C#: Func<int, int> fib = n => n > 1 ? fib(n...
Drowsy asked 30/3, 2011 at 14:54

3

I've spent some time wrapping my head around the Y combinator lately, and I've found that it is usually defined (more or less) as follows (this is in C#, but the language of choice isn't important)...
Frida asked 21/1, 2011 at 20:51

© 2022 - 2024 — McMap. All rights reserved.