letrec Questions

5

Solved

I was a bit confused by the documentation for fix (although I think I understand what it's supposed to do now), so I looked at the source code. That left me more confused: fix :: (a -> a) ->...
Opec asked 24/1, 2011 at 21:34

3

Solved

This is the usual definition of the fixed-point combinator in Haskell: fix :: (a -> a) -> a fix f = let x = f x in x On https://wiki.haskell.org/Prime_numbers, they define a different fixe...
Plage asked 11/12, 2018 at 0:45

2

Solved

So as far as I understand, the following: let, let*, letrec and letrec* are synthetics sugars used in Scheme/Racket. Now, if I have a simple program: (let ((x 1) (y 2)) (+ x y)) It is transl...
Estradiol asked 31/5, 2018 at 15:26

16

It seems quite a few mainstream languages support function literals these days. They are also called anonymous functions, but I don't care if they have a name. The important thing is that a functio...

3

Solved

Its possible to create infinite, circular lists using let rec, without needing to resort to mutable references: let rec xs = 1 :: 0 :: xs ;; But can I use this same technique to write a function...
Hame asked 20/10, 2014 at 21:50

1

Solved

Both letrec and letrec* are in R6RS, but there's only letrec in Racket, no letrec*. What are the differences between these?
Encephalography asked 7/12, 2013 at 11:17

2

Solved

I have a function which computes a fixed point in terms of iterate: equivalenceClosure :: (Ord a) => Relation a -> Relation a equivalenceClosure = fst . List.head -- "guaranteed" to exist ...
Audriaaudrie asked 9/6, 2011 at 22:52

2

Solved

I have been told that the following expression is intended to evaluate to 0, but that many implementations of Scheme evaluate it as 1: (let ((cont #f)) (letrec ((x (call-with-current-continuation...
Apiarian asked 25/10, 2012 at 22:15

1

Solved

Running this code: j = let x = 4 in let x = x * x in x in the interpreter: ghci> j ... no response ... hangs with very little CPU utilization. Why is this? I expected j = 16.
Driscoll asked 10/8, 2012 at 13:13

2

Solved

I don't understand what the differences are between (sorry for the contrived example): (define average (lambda (elems) (define length (lambda (xs) (if (null? xs) 0 (+ 1 (length (cdr xs)))))...
Crankshaft asked 13/7, 2012 at 2:15

1

Solved

Suppose I have a stupid little case class like so: case class Foo(name: String, other: Foo) How can I define a and b immutably such that a.other is b, and b.other is a? Does scala provide some w...
Yb asked 6/6, 2012 at 0:26

2

Solved

How can letrec be implemented without using set!? It seems to me that set! is an imperative programming construct, and that by using it, one loses the benefits of functional programming.
Nb asked 11/12, 2011 at 23:35

3

Solved

While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already...
Austin asked 13/1, 2010 at 22:24
1

© 2022 - 2024 — McMap. All rights reserved.