Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.
tarcieri edited this page Feb 12, 2011 · 8 revisions

Lists are immutable and singly linked. A list literal looks like:

[1,2,3,4,5]

Instance methods

Note: work on List methods is ongoing.

List#[] → obj or nil

  • Ruby equivalent: Array#[]
  • Erlang equivalent: lists:nth/2, lists:seq/2
  • Implemented: partial (Currently only supports simple index lookups)

Retrieve the nth element of a list.

List#all? [{|obj| block}] → true or false

  • Ruby equivalent: Enumerable#all?
  • Erlang equivalent: lists:all/2
  • Implemented: partial (Currently only supports lists:all/2 behavior)

Passes each element of the collection to the given block. The method returns true if the block never returns false or nil. If the block is not given, an implicit block of {|obj| obj} is used (that is all? will return true only if none of the collection members are false or nil.)

List#any? [{|obj| block } ] → true or false

  • Ruby equivalent: Enumerable#any?
  • Erlang equivalent: lists:any/2
  • Implemented: partial (Currently only supports lists:any/2 behavior)

Passes each element of the collection to the given block. The method returns true if the block ever returns a value other than false or nil. If the block is not given, an implicit block of {|obj| obj} is used (that is any? will return true if at least one of the collection members is not false or nil.

List#append(other_list) → list

  • Ruby equivalent: Array#concat
  • Erlang equivalent: lists:append/2
  • Implemented: complete

Appends the elements of other_list to self, returning a new list.

List#each {|item| block} → list

  • Ruby equivalent: Array#each
  • Erlang equivalent: lists:each/2
  • Implemented: partial (lacks Enumerator support)

Calls block once for each element in self, passing that element as a parameter.