juan_gandhi: (Default)
const iterate = f => z => pair(z, () => iterate(f)(f(z)));

const integers = iterate(n => n+1)(0);
juan_gandhi: (Default)
 

70 Observe that, for any two streams, there is in general more than one acceptable order of interleaving. Thus, technically, ‘merge’ is a relation rather than a function—the answer is not a deterministic function of the inputs. We already mentioned (footnote 38 ) that nondeterminism is essential when dealing with concurrency. The merge relation illustrates the same essential nondeterminism, from the functional perspective.
 

71 The object model approximates the world by dividing it into separate pieces. The functional model does not modularize along object boundaries. The object model is useful when the unshared state of the ‘objects’ is much larger than the state that they share. An example of a place where the object viewpoint fails is quantum mechanics, where thinking of things as individual particles leads to paradoxes and confusions. Unifying the object view with the functional view may have little to do with programming, but rather with fundamental epistemological issues.

juan_gandhi: (Default)
См определение merge на схеме; но в джаваскриптовом тексте ошибка.

Если мержируем стрим с самим собой, то просто зависает программа.

Я, короче, предложил им пофиксить эту функцию в джаваскриптовой версии.

Вот тут вот, например.

Бага в том, что если два потока выдали одно и то же значение, то мы его вообще игнорируем и бежим дальше. Соответственно, если делаем merge(integers, integers), и берем его хотя бы второй элемент, то зависнет.

НУ ФИГНЯ ЖЕ. 

Сейчас протестировал на их же упражнении, чуточку модифицировав ответ. Фигня получается.

У основоположников не фигня.

Посмотрим.

https://github.com/source-academy/sicp/pull/194




Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

May 2025

S M T W T F S
    1 2 3
456 7 8 9 10
11 121314151617
18192021222324
25262728293031

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 13th, 2025 05:58 pm
Powered by Dreamwidth Studios