tying-the-knot Questions

2

Solved

Context I asked about patching a recursively-defined list the other day. I'm now trying to bring it up a level by operating on a 2D list instead (a list of lists). I'll use Pascal's triangle as a...
Ricer asked 8/1, 2019 at 17:6

1

Solved

Context We all know the recursively-defined Fibonacci sequence: fibs = 1 : 1 : zipWith (+) fibs (tail fibs) λ> fibs [1,1,2,3,5,9,13,21,34,55,89... Question I'm trying to “patch” it in a fe...
Phosphate asked 31/12, 2018 at 15:22

2

I am trying to form an infinite grid like data structure by tying the knot. This is my approach: import Control.Lens data Grid a = Grid {_val :: a, _left :: Grid a, _right :: Grid a, _down ::...
Buddybuderus asked 18/10, 2017 at 15:27

1

Solved

I'm trying to wrap my head around Cont and callCC, by reducing this function: s0 = (flip runContT) return $ do (k, n) <- callCC $ \k -> let f x = k (f, x) in return (f, 0) lift $ print n ...

3

Solved

The tying-the-knot strategy can be used to construct graphs such as, using a simple two-edged graph as an example: data Node = Node Node Node -- a - b -- | | -- c - d square = a where a = Node b...
Waggle asked 15/10, 2015 at 22:47

1

Solved

As explained on my previous question, it is impossible to differ two graphs made using the tying the knot strategy if you don't have some kind of unique label on your nodes. Using a two-edged graph...
Hebe asked 16/10, 2015 at 0:9

3

Solved

Why isn't iterate defined like iterate :: (a -> a) -> a -> [a] iterate f x = xs where xs = x : map f xs in the Prelude?
Dysteleology asked 20/6, 2015 at 1:39

1

Solved

(Note: this post is a literate-haskell file. You can copy-paste it into a text buffer, save it as someFile.lhs, and then run it using ghc.) Problem description: I want ot create a graph with two d...
Raddled asked 3/1, 2014 at 2:5

4

Solved

Several years ago I took an algorithms course where we were giving the following problem (or one like it): There is a building of n floors with an elevator that can only go up 2 floors at a time...

5

Solved

I'm working on a Haskell project that involves tying a big knot: I'm parsing a serialized representation of a graph, where each node is at some offset into the file, and may reference another node ...
Sleeping asked 16/6, 2012 at 3:34

1

Solved

I have a problem that I don't know how to reason about. I was just about to ask if somebody could help me with the specific problem, but it dawned on me that I could ask a more general question and...
Intellectualize asked 7/7, 2012 at 3:43

1

Solved

I've stumbled upon something that I'm guessing is a bug in Data.Map, but which is also quite possibly a bug in my Haskell knowledge. Hoping somebody can clarify which it is :) Please reference thi...
Tradein asked 24/6, 2012 at 19:28

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

I'm writing a brainfuck interpreter in Haskell, and I came up with what I believe to be a very interesting description of a program: data Program m = Instruction (m ()) (Program m) | Control (m (...
Hazan asked 12/5, 2012 at 0:35

1

Solved

I want to write a slick bit of code (saving me much time to implement otherwise) by tying the knot. It goes roughly like this, n <- myinstr n x where in theory, myinstr should run x to get a ...
Crescantia asked 5/12, 2011 at 0:41

2

Solved

In reading Haskell-related stuff I sometimes come across the expression “tying the knot”, I think I understand what it does, but not how. So, are there any good, basic, and simple to understand ex...
Disable asked 10/12, 2008 at 23:14
1

© 2022 - 2024 — McMap. All rights reserved.