Prelude> head li
Just 1
Prelude> :sp li
-li - [Just 1 | _]
+li - Just 1 : _
Prelude> :p li
-li - [Just 1 | (_t2::[Maybe Integer])]
+li - Just 1 : (_t2::[Maybe Integer])
Prelude> last li
Just 5
Prelude> :sp li
to help us observe how the <literal>li</literal> variable is evaluated progressively as we operate
with it. Note for instance how <quote>last</quote> traverses all the elements of
the list to compute its result, but without evaluating the individual elements.</para>
- <para>Finally note that the Prolog convention of [head | tail] is used by
- <literal>:sprint</literal> to display unevaluated lists.
</para>
</listitem>
</varlistentry>
Prelude> head li
Just 1
Prelude> :sp li
-li - [Just 1 | _]
+li - Just 1 : _
Prelude> last li
Just 5
Prelude> :sp li
The example uses <literal>:sprint</literal> to help us observe how the <literal>li</literal> variable is evaluated progressively as we operate
with it. Note for instance how <quote>last</quote> traverses all the elements of
the list to compute its result, but without evaluating the individual elements.</para>
- <para>Finally note that the Prolog convention of [head | tail] is used by
- <literal>:sprint</literal> to display unevaluated lists.
</para>
</listitem>
</varlistentry>