class Class
:Class
.
func conformed_by(o):
Succeeds if o
contains correspondingly named slots as each field in this class and its superclasses. Note that o
may also contain other slots beyond this.
func instantiated(o):
Succeeds if this class (or one of its subclasses) instantiated o
.
func get_field(name):
Returns the field name
in the class, raising an exception if it does not exist.
func iter_defns():
Successively generates each (field name, field value) pair for the class (note that this does not include slots defined in superclasses).
func set_field(name, val):
Sets the value of field name
to val
, creating name
if it did not previously exist.
func get_supers():
Returns a list of all this parents superclasses.
class Dict
:Dict
.
func del(o):
Deletes the entry o
. If 'o' is not found an exception is raised.
func extend(o):
Adds every element from the dictoinary o
into the dictionary. Key conflicts are resolved in favour of o
i.e. elements in o
overwrite elements in the dictionary being extended.
func find(o, default := fail):
Returns the value of key
. If 'key' is not found, 'default' is returned or, if no default value is specified, it fails. Note that unlike many other fuctions named find
, this only returns a single value.
func get(o, default := fail):
Returns the value of key
. If 'key' is not found, 'default' is returned or, if no default value is specified, an exception is raised.
func iter():
Successively generates each [key, val]
pair in this dictionary.
func iter_keys():
Successively generates each key in this dictionary.
func len():
Returns the number of keys in this dictionary.
func set(key, val):
Sets the value of key
to val
. If key
was previously associated with a value, val
overwrites the previous association. Returns null.
func iter_vals():
Successively generates each value in this dictionary.
class Int
:Number
functions with the following addition:
func idiv(n):
Returns the integer value of dividing this integer by n
.
class List
:List
.
func append(o):
Adds o
to the end of the list.
func extend(c):
Appends each element returned by c.iter()
.
func find(o):
Successively generates each element in the list which compares equal to o
.
func find_index(o):
Successively generates the index of each element in the list which compares equal to o
.
func flattened():
Returns a copy of this list with each sub-list recursively flattened. e.g. flattened([1, 2, [3, [4, 5]], 6])
returns [1, 2, 3, 4, 5, 6]
.
func get_slice(lower := 0, upper := self.len()):
Returns a sub-list of the elements from position lower
(inclusive) to upper
(exclusive). An exception is raised if either index is out of bounds.
func insert(i, o):
Inserts o
at position i
, causing the original values of position i
(inclusive) to self.len()
(exclusive) to be shuffled up by one position. An exception is raised if i
is out of bounds.
func iter(lower := 0, upper := self.len()):
Successively generates, in order, each value in the list.
func len():
Returns the number of entries in the list.
func pop():
Deletes the last position in the list, returning that positions value.
func remove(o):
Successively deletes, in order, each element which equals o
. Returns the value of that entry on each successful deletion, failing when no elements remain to be deleted.
func riter():
Successively generates, in reverse order, each value in the list.
func set_slice(lower := 0, upper := self.len(), c):
Effectively deletes the elements from position lower
(inclusive) to upper
(exclusive) and then successively inserts each element returned by c.iter()
at position lower + position in c
. An exception is raised if either index is out of bounds.
class Module
:Module
.
Module objects have the following slots:
func defn_names():
Successively generates each definition name in the module.
func get_defn(name):
Returns the definition named name
in this module.
func iter_defns():
Successively generates each (definition name, definition value) pair for the module.
class Object
:Object
.
func init():
The standard object initialisation function; effectively a no-op.
func find_slot(name):
Returns the value of the slot name
, or fails if no such slot exists.
func get_slot(name):
Returns the value of the slot name
, raising an exception if no such slot exists.
func iter_slots():
Successively generates each (slot name, slot value) pair for the object.
func set_slot(name, val):
Sets the value of slot name
to val
, creating name
if it did not previously exist.
class Set
:Set
. Note that Converge's sets are mutable.
func add(o):
Adds o
to the set, overwriting the previous object which compared equal to o
if it existed.
func del(o):
Removes the entry o
. If 'o' is not found an exception is raised.
func extend(c):
Successively adds each element returned by c.iter()
to the set.
func find(o, default := fail):
Returns the object which compares equal to o
. If no such object is not found, 'default' is returned or, if no default value is specified, it fails. Note that unlike many other fuctions named find
, this only returns a single value.
func iter():
Successively generates each value in the set.
func len():
Returns the number of entries in the set.
class String
:String
. Note that Converge's strings are immutable, and the API is designed with this in mind.
func find(s):
Successively generates each substring which matches s
(in practice this means that 's' itself will be returned for each match, but is defined this way for consistency with other find
functions).
func find_index(s):
Successively generates, in order, the starting index of each substring which matches s
.
func hash():
Returns this strings hash value.
func get_slice(lower := 0, upper := self.len()):
Returns a sub-string of the characters from position lower
(inclusive) to upper
(exclusive). An exception is raised if either index is out of bounds.
func iter(lower := 0, upper := self.len()):
Successively generates, in order, each character in the string.
func len():
Returns the number of characters in the string.
func lower_cased():
Returns a copy of this string with all characters converted to lower case.
func lstripped():
Returns a copy of this string with all whitespace (tabs, spaces, newlines) removed from its left hand side.
func prefixed_by(s, i := 0):
Succeeds if the string starting at position i
matches s
in its entirety.
func rfind_index(s):
Successively generates, in reverse order, the starting index of each substring which matches s
.
func split(s):
Splits the string on each instance of s
, returning a list of the result.
func stripped():
Returns a copy of this string with all whitespace (tabs, spaces, newlines) removed from both its left and right hand side.
func suffixed_by(s, i := self.len()):
Succeeds if the string ending at position i
matches s
in its entirety.
func upper_cased():
Returns a copy of this string with all characters converted to upper case.
cvd_to_html ©2006-2007 Laurence Tratt