Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my humble opinion, tail and head are more familiar with people with a functional background. When you start passing functions around, they are incredible useful, that's why most functional languages have them implemented and even have shortcut notation to refer to them, like in haskell or even in scala (even if it's not THAT functional, I know)<br> In the "(almost) everything is an object but methods are made in a procedural way" java world, when passing around functions is at least hard and always awkward, head/tail methods are not so useful.<br> For example, check this haskell implementation of quicksort:</p> <pre><code>quicksort :: Ord a =&gt; [a] -&gt; [a] quicksort [] = [] quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) where lesser = filter (&lt; p) xs greater = filter (&gt;= p) xs </code></pre> <p>It relies, among other things, on the ability to easily separate head and tail, but also on being able to filter a collection using a predicate. A java implementation (check <a href="http://www.vogella.de/articles/JavaAlgorithmsQuicksort/article.html" rel="nofollow noreferrer">http://www.vogella.de/articles/JavaAlgorithmsQuicksort/article.html</a>) looks totally different, it is way lower level, and doesn't rely on separating head and tail.<br> Note: The next sentence is totally subjective and based on my personal experience and may be proven wrong, but I think it's true:<br> Most algorithms in functional programming rely on head/tail, in procedural programming you rely on accessing an element in a given position</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload