Streams Path
Tue Oct 01 2024 04:36:21 GMT+0000 (Coordinated Universal Time)
Saved by
@hkrishn4a
function n_of_n_stream(){
function helper(a,b){
return b<= 0
? helper (a+1, a+1)
: pair(a, () => helper(a, b-1));
}
return helper(1,1)
}
function shorten_stream(s,k){
if (is_null(0) || k === 0){
return null;
} else {
return pair( head(s), () => shorten_stream(stream_tail(xs), k-1))
}
}
content_copyCOPY
Comments