Comment

Comment by nunull

> head extracts the first element of a list, which must be non-empty.

Those functions operate on lists. I think it should read as follows.

    const head = (xs) => xs[0];
    const last = (xs) => xs[xs.length-1];
    const tail = (xs) => xs.slice(1);
    const init = (xs) => xs.slice(0, -1);
Am I missing something?
parent nunull 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton