tail and head

View: New views
3 Messages — Rating Filter:   Alert me  

tail and head

by cnb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

why cant i do head([1,2,3]). or head [1,2,3]. ?

head and tail aren't real commands just abstract ones so I always have to do the following?
[A:B]=[1,2,3].
A.
1
B.
[2,3]


Ta semester! - sök efter resor hos Kelkoo.
Jämför pris på flygbiljetter och hotellrum: http://www.kelkoo.se/c-169901-resor-biljetter.html

_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: tail and head

by Vlad Dumitrescu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

You can, it's only that 'head' is actually called 'hd' and 'tail' is 'tl'.

hd([1,2,3])
1

regards,
Vlad

2008/7/22 Circular Function <circularfunc@...>:
why cant i do head([1,2,3]). or head [1,2,3]. ?

head and tail aren't real commands just abstract ones so I always have to do the following?
[A:B]=[1,2,3].
A.
1
B.
[2,3]


Ta semester! - sök efter resor hos Kelkoo.
Jämför pris på flygbiljetter och hotellrum: http://www.kelkoo.se/c-169901-resor-biljetter.html

_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions

Re: tail and head

by Christian S-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The names of the functions are erlang:hd/1 and erlang:tl/1

And yes, "[A|B] = List." is another way to deconstruct a list.

2008/7/22 Circular Function <circularfunc@...>:
> why cant i do head([1,2,3]). or head [1,2,3]. ?
_______________________________________________
erlang-questions mailing list
erlang-questions@...
http://www.erlang.org/mailman/listinfo/erlang-questions