Preview:
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))
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter