Longest common prefix: Difference between revisions
Content added Content deleted
m (→JS ES6: Updated primitives and output.) |
(→JS ES6) |
||
Line 1,901: | Line 1,901: | ||
// allSame :: [a] -> Bool |
// allSame :: [a] -> Bool |
||
const allSame = xs => |
const allSame = xs => |
||
// True if xs is empty, or every item in the |
|||
// tail of the list is identical to the head. |
|||
0 === xs.length || (() => { |
0 === xs.length || (() => { |
||
const |
const [h, ...t] = xs; |
||
return |
return t.every(x => h === x); |
||
})(); |
})(); |
||