Date
+(aDuration)
Return a new Date with the receiver's value plus an amount
of time specified by aDuration object to the receiver.
+=(aDuration)
Add aDuration to the receiver. Returns self.
-(aDurationOrDate)
Return a new Date with the receiver's value minus an amount of time specified by aDuration to the receiver. Returns self.
-=(aDuration)
Subtract aDuration from the receiver. Returns self.
asAtomDate
Returns the date formatted as a valid atom date (rfc4287) in the system's timezone.
asNumber
Returns the date as seconds since 1970 UTC.
asSerialization
Returns a serialization (sequence) of the date that allows for perfect reconstruction of the timestamp.
asString(optionalFormatString)
Returns a string representation of the receiver using the
receivers format. If the optionalFormatString argument is present, the
receiver's format is set to it first. Formatting is according to ANSI C
date formatting rules.
%a abbreviated weekday name (Sun, Mon, etc.)
%A full weekday name (Sunday, Monday, etc.)
%b abbreviated month name (Jan, Feb, etc.)
%B full month name (January, February, etc.)
%c full date and time string
%d day of the month as two-digit decimal integer (01-31)
%H hour as two-digit 24-hour clock decimal integer (00-23)
%I hour as two-digit 12-hour clock decimal integer (01-12)
%m month as a two-digit decimal integer (01-12)
%M minute as a two-digit decimal integer (00-59)
%p either "AM" or "PM"
%S second as a two-digit decimal integer (00-59)
%U number of week in the year as two-digit decimal integer (00-52)
with Sunday considered as first day of the week
%w weekday as one-digit decimal integer (0-6) with Sunday as 0
%W number of week in the year as two-digit decimal integer (00-52)
with Monday considered as first day of the week
%x full date string (no time); in the C locale, this is equivalent
to "%m/%d/%y".
%y year without century as two-digit decimal number (00-99)
%Y year with century as four-digit decimal number
%Z time zone name (e.g. EST);
null string if no time zone can be obtained
%% stands for '%' character in output string.
asUTC
Changes the timezone of this date to utc
clock
Returns a number containing the number of seconds
of processor time since the beginning of the program or -1 if unavailable.
convertToLocal
Converts self date from a UTC date to the equivalent local date
convertToUTC
Converts self from a local date to the equivalent UTC date
convertToZone(offset, isDST)
Converts self to an equivalent data in a zone with offset (minutes west) and DST (true, false).
copy(aDate)
Sets the receiver to be the same date as aDate. Returns self.
cpuSecondsToRun(expression)
Evaluates message and returns a Number whose value
is the cpu seconds taken to do the evaluation.
day
Returns a number containing the day of the month of the receiver.
format
Returns the format string for the receiver. The default is "%Y-%m-%d %H:%M:%S %Z".
fromNumber(aNumber)
Sets the receiver to be aNumber seconds since 1970.
fromSerialization
Sets the date based on the serialization sequence. Return self.
fromString(aString, formatString)
Sets the receiver to the date specified by aString as parsed according to the given formatString. See the Date asString method for formatting rules. Returns self.
gmtOffset
Returns the system's timezone string. E.g., +1300 or -0500.
gmtOffsetSeconds
Returns the system's seconds east of UTC.
hour
Returns a number containing the hour of the day(0-23) of the receiver.
isDST
Returns true if the Date is set to use DST. Posix only.
isDaylightSavingsTime
Returns self if Daylight Saving Time is in effect for the receiver, otherwise returns Nil.
isPast
Returns true if the receiver is a date in the past.
isToday
Returns true if the receiver's date is today's date.
isValidTime(hour, min, sec)
Returns self if the specified time is valid, otherwise returns Nil.
A negative value will count back; i.e., a value of -5 for the hour,
will count back 5 hours to return a value of 19. No adjustment is
done for values above 24.
minute
Returns a number containing the minute of the hour(0-59) of the receiver.
month
Returns a number containing the month(1-12) of the year of the receiver.
now
Sets the receiver to the current time. Returns self.
print
Prints the receiver. Returns self.
second
Returns a number containing the seconds of the minute(0-59) of the receiver. This number may contain fractions of seconds.
secondsSince(aDate)
Returns a number of seconds of between aDate and the receiver.
secondsSinceNow(aDate)
Returns the number of seconds since aDate.
secondsToRun(expression)
Evaluates message and returns a Number whose value is the number of seconds taken to do the evaluation
setDay(aNumber)
Sets the day of the receiver. Returns self.
setGmtOffset
Set the number of minutes west of GMT for this Date's zone
setHour(aNumber)
Sets the hour of the receiver. Returns self.
setMinute(aNumber)
Sets the minute of the receiver. Returns self.
setMonth(aNumber)
Sets the month(1-12) of the receiver. Returns self.
setSecond(aNumber)
Sets the second of the receiver. Returns self.
setYear(aNumber)
Sets the year of the receiver.
today
Set the receiver to the current date, no time information
is included. See `now' for the current date and time.
year
Returns a number containing the year of the receiver.
zone
Returns a string containing the system's time zone code.
File
Encapsulates file i/o. Here's an example of opening a file,
and reversing its lines:
file := File clone openForUpdating("/tmp/test")
lines := file readLines reverse
file rewind
lines foreach(line, file write(line, "\n"))
file close
appendToContents(aSeq)
Appends to the contents of the file with aSeq. Returns self.
asBuffer
Opens the receiver in read only mode, reads the whole
contents of the file into a buffer object, closes the file and returns the buffer.
at(aNumber)
Returns a Number containing the byte at the specified
byte index or Nil if the index is out of bounds.
atPut(positionNumber, byteNumber)
Writes the byte value of byteNumber to the file position
positionNumber. Returns self.
baseName
Returns File's name without an extension (returned Sequence consists of all characters up to final period ["."] character).
close
Closes the receiver if open, otherwise does nothing. Returns self.
When the file was opened via popen, sets either exitStatus or
termSignal to the exit status on normal exit, or the signal causing
abnormal termination.
containingDirectory
Deprecated. See parentDirectory.
contents
Returns contents of the file as a mutable Sequence of bytes.
copyToPath(destinationPath)
Copies the file to the specified path.
copyToPathWithoutYielding(destinationPath)
Copies the file to the specified path without yielding.
create
Creates an empty file at the file's path. Returns self on success, nil on failure.
descriptor
Returns the file's descriptor as a number.
exists(optionalPath)
Returns true if the file path exists, and false otherwise.
If optionalPath string is provided, it tests the existance of that path instead.
exitStatus
System's close status (after file close).
flush
Forces any buffered data to be written to disk. Returns self.
foreach(optionalIndex, value, message)
For each byte, set index to the index of the byte
and value to the number containing the byte value and execute aMessage.
Example usage:
aFile foreach(i, v, writeln("byte at ", i, " is ", v))
aFile foreach(v, writeln("byte ", v))
foreachLine(optionalLineNumber, line, message)
For each line, set index to the line number of the line
and line and execute aMessage.
Example usage:
aFile foreachLine(i, v, writeln("Line ", i, ": ", v))
aFile foreach(v, writeln("Line: ", v))
groupId
Returns a Number containing the group id associated with the file's path.
isAtEnd
Returns true if the file is at its end. Otherwise returns false.
isDirectory
Returns true if the receiver's path points to a directory, false otherwise.
isLink
Returns true if the receiver's path points to a link, false otherwise.
isOpen
Returns self if the file is open. Otherwise returns Nil.
isPipe
Returns true if the receiver is a pipe, false otherwise.
isRegularFile
Returns true if the receiver's file descriptor is a regular file, false otherwise.
isSocket
Returns true if the receiver's file descriptor is a Socket, false otherwise.
isUserExecutable
Returns true if the receiver is user group executable, false otherwise.
lastAccessDate
Returns a Date object containing the last date and
time the file was accessed.
lastDataChangeDate
Returns a Date object containing the last date and
time the file's contents were changed.
lastInfoChangeDate
Returns a Date object containing the last date and
time the file's meta info was changed.
mode
Returns the open mode of the file(either read, update or append).
moveTo(pathString)
Moves the file specified by the receiver's path to the
new path pathString. Raises an File doesNotExist exception if the
file does not exist or a File nameConflict exception if the file
nameString already exists.
name
Returns the last path component of the file path.
open(optionalPathString)
Opens the file. Creates one if it does not exist.
If the optionalPathString argument is provided, the path is set to it before
opening. Returns self or raises an File exception on error.
openForAppending(optionalPathString)
Sets the file mode to append (writing to the end of the file)
and calls open(optionalPathString).
openForReading(optionalPathString)
Sets the file mode to read (reading only) and calls open(optionalPathString).
openForUpdating(optionalPathString)
Sets the file mode to update (reading and writing) and calls
open(optionalPathString). This will not delete the file if it already exists.
Use the remove method first if you need to delete an existing file before opening a new one.
parentDirectory
Returns a File for the directory that is the parent directory of this object's path.
path
Returns the file path of the receiver.
popen
Open the file as a pipe. Return self.
Closing a popen'ed file sets exitStatus or termSignal
to reflect the status or cause of the child processes' termination.
position
Returns the current file pointer byte position as a Number.
positionAtEnd
Sets the file position pointer to the end of the file.
protectionMode
Returns a Number containing the protection mode
associated with the file's path.
readBufferOfLength(aNumber)
Reads a Buffer of the specified length and returns it.
Returns Nil if the end of the file has been reached.
readLine
Reads the next line of the file and returns it as a
string without the return character. Returns Nil if the
end of the file has been reached.
readLines
Returns list containing all lines in the file.
readStringOfLength(aNumber)
Reads a String of the specified length and returns it.
Returns Nil if the end of the file has been reached.
readToBufferLength(aBuffer, aNumber)
Reads at most aNumber number of items and appends them to aBuffer.
Returns number of items read.
readToEnd(chunkSize)
Reads chunkSize bytes (4096 by default) at a time until end of file is reached. Returns a sequence containing the bytes read from the file.
remove
Removes the file specified by the receiver's path.
Raises an error if the file exists but is not removed. Returns self.
reopen(otherFile, mode)
Reopen's otherFile and redirects its stream to this file's path using mode.
If mode is omitted, it is copied from otherFile.
Returns self or raises a File exception on error.
rewind
Sets the file position pointer to the beginning of the file.
setContents(aSeq)
Replaces the contents for the file with aSeq. Returns self.
setPath(aString)
Sets the file path of the receiver to pathString.
The default path is an empty string. Returns self.
setPosition(aNumber)
Sets the file position pointer to the byte specified by aNumber. Returns self.
setStreamDestination(aBuffer)
Set the buffer to be used for future stream operations.
size
Returns the file size in bytes.
standardError
Returns a new File whose stream is set to the standard error stream.
standardInput
Returns a new File whose stream is set to the standard input stream.
standardOutput
Returns a new File whose stream is set to the standard output stream.
startStreaming
Begin streamed read to stream destination set by setStreamDestination(aBuffer).
stat
Updates the receiver's meta info cache.
statSize
Returns the file's size in bytes as a Number.
streamDestination
The buffer object to be used for future stream operations.
streamReadSize
Size of stream buffer used for streaming operations
streamTo(aBuffer)
Perform streamed reading to given buffer. The buffer will be appended with chunks of size streamReadSize until EOF. The final chunk may be less than streamReadSize.
streamToWithoutYielding(aBuffer)
Perform streamed reading to given buffer without yielding between reads.
temporaryFile
Returns a new File object with an open temporary file. The file is
automatically deleted when the returned File object is closed or garbage collected.
termSignal
Pipe's terminating signal (after file close opened via popen).
thisSourceFile
Returns a File representing the system file in which this Io code exists.
truncateToSize(numberOfBytes)
Trunctates the file's size to the numberOfBytes. Returns self.
userId
Returns a Number containing the user id associated with the file's path.
with(aPath)
Returns a new instance with the provided path.
write(aSequence1, aSequence2, ...)
Writes the arguments to the receiver file. Returns self.
List
A mutable array of values. The first index is 0.
anyOne
Returns a random element of the receiver or nil if the receiver is empty.
append(anObject1, anObject2, ...)
Appends the arguments to the end of the list. Returns self.
appendIfAbsent(anObject)
Adds each value not already contained by the receiver, returns self.
appendSeq(aList1, aList2, ...)
Add the items in the lists to the receiver. Returns self.
asEncodedList
Returns a Sequence with an encoding of the list.
Nil, Number and Symbol objects are copied into the encoding, for other object
types, referenceIdForObject(item) will be called to request a reference id for
the object.
Also see: List fromEncodedList.
asJson
Returns JSON encoded representation of a List.
asMap
The reverse of Map asList: converts a list of lists (key-value pairs) into
a Map. The first item of each pair list must be a sequence. The second item
is the value.
asMessage
Converts each element in the list to unnamed messages with their cached result
set to the value of the element (without activating).Returns an unnamed message
whose arguments map 1:1 with the elements (after being converted to messages themselves).
at(index)
Returns the value at index. Returns Nil if the index is out of bounds.
atInsert(index, anObject)
Inserts anObject at the index specified by index.
Adds anObject if the index equals the current count of the receiver.
Raises an exception if the index is out of bounds. Returns self.
atPut(index, anObject)
Replaces the existing value at index with anObject.
Raises an exception if the index is out of bounds. Returns self.
average
Returns the average of the items.
capacity
Returns the number of potential elements the receiver can hold before it needs to grow.
contains(anObject)
Returns true if the receiver contains anObject, otherwise returns false.
containsAll(list)
Returns true the target contains all of the items in the argument list.
containsAny(list)
Returns true the target contains any of the items in the argument list.
containsIdenticalTo(anObject)
Returns true if the receiver contains a value identical to anObject, otherwise returns false.
copy(v)
Replaces self with v list items. Returns self.
cursor
Returns a ListCursor for the receiver.
detect(optionalIndex, value, message)
Returns the first value for which the message evaluates to a non-nil. Example:
list(1, 2, 3, 4) detect(i, v, v > 2)
==> 3
list(1, 2, 3, 4) detect(v, v > 2)
==> 3
difference(list)
Returns a new list containing items from the target list which aren't in the argument list.
empty
Removes all items from the receiver.
first(optionalSize)
Returns the first item or Nil if the list is empty.
If optionalSize is provided, that number of the first items in the list are returned.
flatten
Creates a new list, with all contained lists flattened into the new list. For example:
list(1,2,list(3,4,list(5))) flatten
==> list(1, 2, 3, 4, 5)
foreach(optionalIndex, value, message)
Loops over the list values setting the specified index and
value slots and executing the message. Returns the result of the last
execution of the message. Example:
list(1, 2, 3) foreach(i, v, writeln(i, " = ", v))
list(1, 2, 3) foreach(v, writeln(v))
fromEncodedList(aSeq)
Returns a List with the decoded Nils, Symbols and Numbers from the input raw array.
For each object reference encounters, objectForReferenceId(id) will be called to
allow the reference to be resolved.
Also see: List asEncodedList.
indexOf(anObject)
Returns the index of the first occurrence of anObject
in the receiver. Returns Nil if the receiver doesn't contain anObject.
insertAfter(item, afterItem)
Inserts item after first occurance of afterItem and returns self.
If afterItem is not found, item is appended to the end of the list.
insertAt(item, index)
Inserts item at the specified index. Raises an exception if the index is out of bounds. Returns self.
insertBefore(item, beforeItem)
Inserts item before first occurance of beforeItem or to the end of the list if beforeItem is not found. Returns self.
intersect(list)
Returns a new list containing the common values from the target and argument lists.
itemCopy
Returns a new list containing the items from the receiver.
join(optionalSeparator)
Returns a Sequence of the concatenated items with
optionalSeparator between each item or simply the concatenation of the items if no optionalSeparator is supplied.
join(optionalSeperator)
Returns a String with the elements of the receiver concatenated into one String.
If optionalSeperator is provided, it is used to separate the concatenated strings.
This operation does not respect string encodings.
justSerialized(stream)
Writes the receiver's code into the stream.
last(optionalSize)
Returns the last item or Nil if the list is empty.
If optionalSize is provided, that number of the last items in the list are returned.
map(optionalIndex, value, message)
Same as calling mapInPlace() on a clone of the receiver, but more efficient.
mapInPlace
Same as map, but result replaces self.
pop
Returns the last item in the list and removes it
from the receiver. Returns nil if the receiver is empty.
preallocateToSize(aNumber)
Preallocates array memory to hold aNumber number of items.
prepend(anObject1, anObject2, ...)
Inserts the values at the beginning of the list. Returns self.
push(anObject1, anObject2, ...)
Same as add(anObject1, anObject2, ...).
reduce
Also known as foldl or inject. Combines values in target starting on the left.
If no initial value is paseed the head of the list is used.
Io> list(1, 2, 3) reduce(+)
==> 6
Io> list(1, 2, 3) reduce(xs, x, xs + x)
==> 6
Io> list(1, 2, 3) reduce(+, -6) // Passing the initial value.
==> 0
Io> list(1, 2, 3) reduce(xs, x, xs + x, -6)
==> 0
remove(anObject, ...)
Removes all occurrences of the arguments from the receiver. Returns self.
removeAt(index)
Removes the item at the specified index and returns the value removed.
Raises an exception if the index is out of bounds.
removeFirst
Returns the first item and removes it from the list. nil is returned if the list is empty.
removeLast
Returns the last item and removes it from the list. nil is returned if the list is empty.
removeSeq
Removes each of the items from the current list which are contained in the sequence passed in.
rest
Returns a copy of the list but with the first element removed.
reverse
Reverses the ordering of all the items of the receiver. Returns copy of receiver.
reverseForeach(index, value, message)
Same as foreach, but in reverse order.
reverseInPlace
Reverses the ordering of all the items in the receiver. Returns self.
reverseReduce
Also known as foldr or inject. Combines values in target starting on the right.
If no initial value is paseed the head of the list is used. See List reverse for examples.
second
Returns third element (same as at(2))
select(optionalIndex, value, message)
Like foreach, but the values for which the result of message are non-nil are returned
in a new List. Example:
list(1, 5, 7, 2) select(i, v, v > 3) print
==> 5, 7
list(1, 5, 7, 2) select(v, v > 3) print
==> 5, 7
select(optionalIndex, value, message)",
"Like foreach, but the values for which the result of
message are non-nil are returned in a new List. Example:
list(1, 5, 7, 2) select(i, v, v > 3) print
==> 5, 7
list(1, 5, 7, 2) select(v, v > 3) print
==> 5, 7
selectInPlace
Same as select, but result replaces self.
setSize
Sets the size of the receiver by either removing excess items or adding nils as needed.
shuffle
Randomizes the ordering of all the items of the receiver. Returns copy of receiver.
shuffleInPlace
Randomizes the order of the elements in the receiver. Returns self.
size
Returns the number of items in the receiver.
slice(startIndex, endIndex, step)
Returns a new string containing the subset of the receiver
from the startIndex to the endIndex. The endIndex argument
is optional. If not given, it is assumed to be the end of the string.
Step argument is also optional and defaults to 1, if not given.
However, since Io supports positional arguments only, you need to
explicitly specify endIndex, if you need a custom step.
sliceInPlace(startIndex, endIndex, step)
Returns the receiver containing the subset of the
receiver from the startIndex to the endIndex. The endIndex argument
is optional. If not given, it is assumed to be the end of the string.
Step argument is also optional and defaults to 1.
sort
Returns a new list containing the sorted items from the receiver.
sortBy(aBlock)
Returns a new list containing the items from the receiver, sorted using aBlock as compare function. Example:
list(1, 3, 2, 4, 0) sortBy(block(a, b, a > b))
==> list(4, 3, 2, 1, 0)
sortInPlace(optionalExpression)
Sorts the list using the compare method on the items. Returns self.
If an optionalExpression is provided, the sort is done on the result of the evaluation
of the optionalExpression on each value.
sortInPlaceBy(aBlock)
Sort the list using aBlock as the compare function. Returns self.
sum
Returns the sum of the items.
swapIndices(index1, index2)
Exchanges the object at index1 with the object at index2.
Raises an exception if either index is out of bounds. Returns self.
union(list)
Returns a new list containing items from the target and items which are only in the argument list.
unique
Returns a new list containing all the values in the target, but no duplicates.
uniqueCount
Returns a list of list(value, count) for each unique value in self.
with(anObject, ...)
Returns a new List containing the arguments.
Number
A container for a double (a 64bit floating point number on most platforms).
%(aNumber)
Returns the receiver modulus aNumber.
&(aNumber)
Returns a new number with the bitwise AND of the receiver and aNumber.
*(aNumber)
Returns a new number that is the product of the receiver and aNumber.
**(aNumber)
Same as pow(aNumber).
+(aNumber)
Returns a new number that is the sum of the receiver and aNumber.
-(aNumber)
Returns a new number that is the difference of the receiver and aNumber.
/(aNumber)
Returns a new number with the value of the receiver divided by aNumber.
<<(aNumber)
Shifts the bits of the receiver left by the number of places specified by aNumber.
>>(aNumber)
Shifts the bits of the receiver right by the number of places specified by aNumber.
^(aNumber)
Returns the bitwise xor with the receiver (both numbers are converted to longs for the operation).
abs
Returns a number with the absolute value of the receiver.
acos
Returns a number with the arc cosine of the receiver.
asBinary
Returns the number as binary digits inside a string. 42 asBinary -> "101010"
asBuffer(optionalNumberOfBytes)
Returns a Buffer containing a the number of bytes specified by
optionalNumberOfBytes (up to the size of a double on the platform) of the receiver.
If no optionalNumberOfBytes is specified, it is assumed to be the number of bytes
in a double on the host platform.
asCharacter
Returns a String containing a single character whose
value is the value of the first byte of the receiver.
Returns nil if the number has no valid UCS mapping.
asHex
Returns the number as hex digits inside a string. 97 asHex -> "61"
asLowercase
Returns a new Number containing a lower case version of the receiver.
asOctal
Returns the number as octal digits inside a string. 436 asOctal -> "664"
asString(optionalIntegerDigits, optionalFactionDigits)
Returns a string representation of the receiver. For example:
1234.5678 asString(0, 2)
would return:
1234.57
asUint32Buffer
Returns a Sequence containing a 4 byte representation of the uint32 value of the receiver.
asUppercase
Returns a new Number containing a upper case version of the receiver.
asin
Returns a number with the arc sine of the receiver.
at(bitIndexNumber)
Returns a new Number containing 1 if the receiver cast to a long
has its bit set to 1 at bitIndexNumber. Otherwise returns 0.
atan
Returns a number with the arc tangent of the receiver.
atan2(aNumber)
Returns a number with the arc tangent of y/x where y is the receiver and x is aNumber.
between(aNumber1, aNumber2)
Returns true if the receiver's value is between or
equal to aNumber1 and aNumber2, otherwise returns false.
bitwiseAnd(aNumber)
Returns a new number with the bitwise AND of the receiver and aNumber.
bitwiseComplement
Returns a new number with the bitwise complement of the
receiver. (The 0 bits become 1s and the 1 bits become 0s. )
bitwiseOr(aNumber)
Returns a new number with the bitwise AND of the receiver and aNumber.
bitwiseXor(aNumber)
Returns a new number with the bitwise XOR of the receiver and aNumber.
ceil
Returns the a number with the receiver's value rounded up to
the nearest integer if its fractional component is greater than 0.
clip(aNumber1, aNumber2)
Returns self if the receiver is between aNumber1 and aNumber2.
Returns aNumber1 if it is less than aNumber1. Returns aNumber2 if it is greater than aNumber2.
combinations(size)
Returns the combinations where the receiver is the number of different objects and size is the number to be arranged.
constants
Object containing number constants e, inf, nan and pi.
cos
Returns the cosine of the receiver.
cubed
Returns the cube of the receiver.
doubleMin
Returns the minimum double precision float value.
e
Returns the constant e.
exp
Returns e to the power of the receiver.
factorial
Returns the factorial of the receiver.
floatMax
Returns the maximum double precision float value.
floatMin
Returns the minimum float value.
floor
Returns a number with the receiver's value rounded
down to the nearest integer if its fractional component is not 0.
inf
Returns a not-a-number constant.
integerMax
Returns the maximum integer value.
integerMin
Returns the minimum integer value.
isAlphaNumeric
Returns true if
receiver is an alphanumeric character value
, false otherwise.
isControlCharacter
Returns true if
receiver is a control character value
, false otherwise.
isDigit
Returns true if
receiver is a numeric digit value
, false otherwise.
isEven
Returns true if
integer form of the receiver is even
, false otherwise.
isGraph
Returns true if
the receiver is a printing character value except space
, false otherwise.
isHexDigit
Returns true if
the receiver is a hexadecimal character value
, false otherwise.
isInASequenceSet
Return true if receiver is in one of the Sequence sequenceSets, otherwise false.
isLetter
Returns true if
receiver is a letter character value
, false otherwise.
isLowercase
Returns true if
the receiver is a lowercase character value
, false otherwise.
isNan
Returns true if the receiver is not a number. Otherwise returns false.
isOdd
Returns true if
integer form of the receiver is odd
, false otherwise.
isPrint
Returns true if
the receiver is a printing character value, including space
, false otherwise.
isPunctuation
Returns true if
the receiver is a punctuation character value
, false otherwise.
isSpace
Returns true if
the receiver is a space, formfeed, newline carriage return, tab or vertical tab character value
, false otherwise.
isUppercase
Returns true if
the receiver is a uppercase character value
, false otherwise.
justSerialized(stream)
Writes the receiver's code into the stream.
log
Returns the logarithm of the receiver. The base
is taken as the value of the first argument or the constant e if
the first argument is omitted.
log10
Returns the base 10 logarithm of the receiver.
log2
Returns the base 2 logarithm of the receiver.
longMax
Returns the maximum long value.
longMin
Returns the minimum long value.
max(aNumber)
Returns the greater of the receiver and aNumber.
min(aNumber)
Returns the lesser of the receiver and aNumber.
minMax(low, high)
Returns a number between or equal to low and high. If the receiver is equal to or between low and high, the receiver is returned. If the receiver is less than low, low is returned. If the receiver is greater than high, high is returned.
mod(aNumber)
Returns the receiver modulus aNumber.
nan
Returns a infinity constant.
negate
Returns new number that is negated version of the receiver.
permutations(size)
Returns the permutations where the receiver is the number of different objects and size is the number to be arranged.
pi
Returns the constant pi.
pow(aNumber)
Returns the value of the receiver to the aNumber power.
repeat(optionalIndex, expression)
Evaluates message a number of times that corresponds to the receivers
integer value. This is significantly faster than a for() or while() loop.
round
Returns a number with the receiver's value rounded up to
the nearest integer if its fraction component is >= .5 or rounded up to the nearest integer otherwise.
roundDown
Returns a number with the receiver's value rounded down to
the nearest integer if its fraction component is <= .5 or rounded up the the nearest integer otherwise.
shortMax
Returns the maximum short value.
shortMin
Returns the minimum short value.
sin
Returns the sine of the receiver.
sqrt
Returns the square root of the receiver.
squared
Returns the square of the receiver.
tan
Returns the tangent of the receiver.
toBase(base)
Returns the number in another base. 42 toBase(2) -> "101010"
toBaseWholeBytes(base)
Returns the number in another base printing out entire bytes. 42 toBaseWholeBytes(2) -> "00101010"
toggle
Returns 1 if the receiver is 0. Returns 0 otherwise.
unsignedIntMax
Returns the maximum unsigned int value.
unsignedLongMax
Returns the maximum unsigned long value.
unsignedShortMax
Returns the minimum unsigned int value.
|(aNumber)
Returns a new number with the bitwise OR of the receiver and aNumber.
Object
An Object is a key/value dictionary with string keys and values of any type.
The prototype Object contains a clone slot that is a CFuntion that creates new objects.
When cloned, an Object will call its init slot (with no arguments).
!=(aValue)
Returns true the receiver is not equal to aValue, false otherwise.
(expression)
The '' method evaluates the argument and returns the result.
-(aNumber)
Returns the negative version of aNumber.
Raises an exception if argument is not a number.
..(arg)
.. is an alias for: method(arg, self asString append(arg asString))
<(expression)
Evaluates argument and returns self if self is less or Nil if not.
<=(expression)
Evaluates argument and returns self if self is less
than or equal to it, or Nil if not.
==(aValue)
Returns true if receiver and aValue are equal, false otherwise.
>(expression)
Evaluates argument and returns self if self is greater than it, or Nil if not.
>=(expression)
Evaluates argument and returns self if self is greater
than or equal to it, or Nil if not.
?(aMessage)
description: Sends the message aMessage to the receiver if it can respond to it. Example:
MyObject test // performs test
MyObject ?test // performs test if MyObject has a slot named test
The search for the slot only follows the receivers proto chain.
@
Sends asynchronous message to an object, returns a FutureProxy.
Caller coroutine is paused when proxy is accessed (i.e. message is sent)
till result is ready. Proxy will become an actual result when it is ready.
See IoGuide for more information.
Usage: obj @someMethod(a, b, c)
@@
Same as Object @, but returns nil instead of FutureProxy.
Might be useful in a command line or as a last expression in a block/method when
you don't want to return a future.
NullCharacter
A sequence with a single zero byte.
actorProcessQueue
Processes each message in a queue, yielding between each message.
actorRun
Starts actor mode if not started already. Basically, sets actorProcessQueue for later execution.
ancestorWithSlot(slotName)
Returns the first ancestor of the receiver that contains
a slot of the specified name or Nil if none is found.
ancestors
Returns a list of all of the receiver's ancestors as found by recursively following the protos links.
and(arg)
Evaluates argument and returns the result.
appendProto(anObject)
Appends anObject to the receiver's proto list. Returns self.
apropos
Prints out Protos Core slot descriptions.
argIsActivationRecord
Note: seems to be an obsolete method.
argIsCall(arg)
Returns true if arg is an activation context (i.e. Call object)
Note: this is used internally in one place only (Coroutine callStack).
Refactoring should be considered.
asSimpleString
Returns _ string.
asString
Same as slotSummary.
become(anotherObject)
Replaces receiver with anotherObject and returns self.
Useful for implementing transparent proxies. See also FutureProxy and Object @.
Note: primitives cannot become new values.
block(args..., body)
Creates a block and binds it to the sender context (i.e. lexical context).
In other words, block locals' proto is sender's locals.
args is a list of formal arguments (can be empty).
body is evaluated in the context of Locals object.
See also
Object method.
Io> block(x, x*2) scope == thisContext
==> true
break(optionalReturnValue)
Break the current loop, if any.
checkMemory()
accesses memory in the IoObjectData struct that should be accessible. Should cause a memory access
exception if memory is corrupt.
clone
Returns a clone of the receiver.
cloneWithoutInit
Returns a clone of the receiver but does not call init.
compact
Compact the memory for the object if possible. Returns self.
compactState
Attempt to compact the memory of the IoState if possible.
compare(anObject)
Returns a number containing the comparison value of the target with anObject.
contextWithSlot(slotName)
Returns the first context (starting with the receiver and following the lookup path)
that contains a slot of the specified name or Nil if none is found.
continue
Skip the rest of the current loop iteration and start on
the next, if any.
coroDo(code)
Creates a new coro to be run in a context of sender and yields to it.
Returns a coro.
coroDoLater(code)
Returns a new coro to be run in a context of sender.
New coro is moved to the top of the yieldingCoros queue to be executed
when current coro yields.
Note: run target is self (i.e. receiver), not call sender as in coroDo.
coroFor(code)
Returns a new coro to be run in a context of sender.
coroWith(code)
Returns a new coro to be run in a context of receiver.
currentCoro
Returns the currently running coroutine.
debugOff
Sets debugWriteln to nil. Returns self.
debugOn
Sets debugWriteln to writeln. Returns self.
debugWriteln
Method for writing debug messages (nil/writeln by default)
deprecatedWarning(optionalNewName)
Prints a warning message that the current method is deprecated.
If optionalNewName is supplied, the warning will suggest using that instead.
Returns self.
do(expression)
Evaluates the message in the context of the receiver. Returns self.
doFile(pathString)
Evaluates the File in the context of the receiver. Returns the result.
pathString is relative to the current working directory.
doMessage(aMessage, optionalContext)
Evaluates the message object in the context of the receiver.
Returns the result. optionalContext can be used to specific the locals
context in which the message is evaluated.
doRelativeFile(pathString)
Evaluates the File in the context of the receiver. Returns the result.
pathString is relative to the file calling doRelativeFile. (Duplicate of relativeDoFile)
doString(aString)
Evaluates the string in the context of the receiver. Returns the result.
doURL(urlString)
Fetches the URL and evals it in the context of the receiver.
evalArg(expression)
The '' method evaluates the argument and returns the result.
evalArgAndReturnNil(expression)
Evaluates the argument and returns nil.
evalArgAndReturnSelf(expression)
Evaluates the argument and returns the target.
for(, , , )
A for-loop control structure. See the io Programming Guide for a full description.
foreach([name,] value, message)
For each slot, set name to the slot's
name and value to the slot's value and execute message. Examples:
myObject foreach(n, v,
writeln("slot ", n, " = ", v type)
)
myObject foreach(v,
writeln("slot type ", v type)
)
foreachSlot(slotName, slotValue, code)
Iterates over all the slots in a receiver. Provides slotValue (non-activated)
along with slotName. Code is executed in context of sender.
slotName and
slotValue
become visible in the receiver (no Locals created! Maybe, it is not the best decision).
Io> thisContext foreachSlot(n, v, n println)
Lobby
Protos
exit
forward
n
v
==> false
forward
Called when the receiver is sent a message it doesn't recognize.
Default implementation raises an "Object doesNotRespond" exception.
Subclasses can override this method to implement proxies or special error handling.
Example:
myProxy forward = method(
messageName := thisMessage name
arguments := thisMessage arguments
myObject doMessage(thisMessage)
)
getLocalSlot(slotNameString)
Returns the value of the slot named slotNameString
(not looking in the object's protos) or nil if no such slot is found.
getSlot(slotNameString)
Returns the value of the slot named slotNameString
(following the lookup path) or nil if no such slot is found.
handleActorException(exception)
Callback for handling exceptions during asynchronous message processing.
Default value: method(e, e showStack)
hasLocalSlot(slotNameString)
Returns true if the slot exists in the receiver or false otherwise.
hasProto(anObject)
Returns true if anObject is found in the proto path of the target, false otherwise.
hasSlot(name)
Returns true if slot is found somewhere in the inheritance chain
(including receiver itself).
if(, , )
Evaluates trueMessage if condition evaluates to a non-Nil.
Otherwise evaluates optionalFalseMessage if it is present.
Returns the result of the evaluated message or Nil if none was evaluated.
ifDebug(code)
Executes code if debugWriteln is not nil.
ifError
Does nothing, returns self.
ifNil(arg)
Does nothing, returns self.
ifNilEval(arg)
Does nothing, returns self.
ifNonNil(arg)
Evaluates argument and returns self.
ifNonNilEval(arg)
Evaluates argument and returns the result.
in(aList)
Same as: aList contains(self)
inlineMethod
Creates a method which is executed directly in a receiver (no Locals object is created).
Io> m := inlineMethod(x := x*2)
Io> x := 1
==> 1
Io> m
==> 2
Io> m
==> 4
Io> m
==> 8
isActivatable
Returns true if the receiver is activatable, false otherwise.
isError
Returns false if not an error.
isIdenticalTo(aValue)
Returns true if the receiver is identical to aValue, false otherwise.
isKindOf(anObject)
Returns true if anObject is in the receiver's ancestors.
isLaunchScript
Returns true if the current file was run on the command line. Io's version of Python's __file__ == "__main__"
justSerialized(stream)
Writes serialized representation to a SerializationStream. Returns stream contents.
[This is unintended side effect! Returned value may change in the future.]
launchFile(pathString)
Eval file at pathString as if from the command line in its folder.
lazySlot(code)
Defines a slot with a lazy initialization code.
Code is run only once: the first time slot is accessed.
Returned value is stored in a regular slot.
Io> x := lazySlot("Evaluated!" println; 17)
Io> x
Evaluated!
==> 17
Io> x
==> 17
Io> x
==> 17
Another form is
lazySlot(name, code):
Io> lazySlot("x", "Evaluated!" println; 17)
Io> x
Evaluated!
==> 17
Io> x
==> 17
Io> x
==> 17
list(...)
Returns a List containing the arguments.
localsForward
CFunction used by Locals prototype for forwarding.
localsUpdateSlot(slotNameString, valueObject)
Local's version of updateSlot mthod.
loop(expression)
Keeps evaluating message until a break.
markClean
Cleans object's slots.
memorySize
Return the amount of memory used by the object.
memorySizeOfState
Returns the number of bytes in the IoState
(this may not include memory allocated by C libraries).
message(expression)
Return the message object for the argument or Nil if there is no argument.
Note: returned object is a mutable singleton. Use "message(foo) clone" if
you wish to modify it.
method(args..., body)
Creates a method.
args is a list of formal arguments (can be empty).
body is evaluated in the context of Locals object.
Locals' proto is a message receiver (i.e. self).
Slot with a method is activatable. Use getSlot(name) to retrieve
method object without activating it (i.e. calling).
See also Object block.
newSlot(slotName, aValue)
Creates a getter and setter for the slot with the name slotName
and sets its default value to aValue. Returns self. For example,
newSlot("foo", 1) would create slot named foo with the value 1 as well as a setter method setFoo().
ownsSlots
A debug method.
pSlots
PDB extension to set a list of slots to persist with PDB.
Creates the specified slots using newSlot and sets them to nil.
pause
Removes current coroutine from the yieldingCoros queue and
yields to another coro. Exits if no coros left.
See Coroutine documentation for more details.
perform(methodName,
, , ...)
Performs the method corresponding to methodName with the arguments supplied.
performWithArgList(methodName, argList)
Performs the method corresponding to methodName with the arguments in the argList.
persist
Force immediate persistence of this object with PDB.
persistData
Force immediate persistence of this object's serialized form (using asSerialization)
into PDB, if possible.
persistMetaData
Force immediate persistence of this object's type data into PDB
persistSlots
Force immediate persistence of this object's dirty slots into PDB.
ppid
This PDB extension returns a unique identifier for this object and registers it
for persistence with PDB.
prependProto(anObject)
Prepends anObject to the receiver's proto list. Returns self.
print
Prints a string representation of the object. Returns Nil.
println
Same as print, but also prints a new line. Returns self.
proto
Same as; method(self protos first)
protos
Returns a copy of the receiver's protos list.
raiseIfError
Does nothing, returns self.
relativeDoFile(pathString)
Evaluates the File in the context of the receiver. Returns the result.
pathString is relative to the file calling doRelativeFile. (Duplicate of doRelativeFile)
removeAllProtos
Removes all of the receiver's protos. Returns self.
removeAllSlots
Removes all of the receiver's slots. Returns self.
removeProto(anObject)
Removes anObject from the receiver's proto list if it
is present. Returns self.
removeSlot(slotNameString)
Removes the specified slot (only) in the receiver if it exists. Returns self.
resend
Send the message used to activate the current method to the Object's proto.
For example:
Dog := Mammal clone do(
init := method(
resend
)
)
Calling Dog init will send an init method to Mammal, but using the Dog's context.
return(anObject)
Return anObject from the current execution block.
returnIfError
Does nothing, returns self.
returnIfNonNil
Returns the receiver from the current execution block if it is non nil.
Otherwise returns the receiver locally.
serialized
Returns a serialized representation of the receiver.
Io> Object clone do(x:=1) serialized
==> Object clone do(
x := 1
)
serializedSlots(stream)
Writes all slots to a stream.
serializedSlotsWithNames(names, stream)
Writes selected slots to a stream.
setIsActivatable(aValue)
When called with a non-Nil aValue, sets the object
to call its activate slot when accessed as a value. Turns this behavior
off if aValue is Nil. Only works on Objects which are not Activatable
Primitives (such as CFunction or Block). Returns self.
setPpid
PDB extension to set the value returned by ppid.
setProto(anObject)
Sets the first proto of the receiver to anObject, replacing the
current one, if any. Returns self.
setProtos(aList)
Replaces the receiver's protos with a copy of aList. Returns self.
setSlot(slotNameString, valueObject)
Sets the slot slotNameString in the receiver to
hold valueObject. Returns valueObject.
setSlotWithType(slotNameString, valueObject)
Sets the slot slotNameString in the receiver to
hold valueObject and sets the type slot of valueObject
to be slotNameString. Returns valueObject.
shallowCopy
Returns a shallow copy of the receiver.
shouldPersistByDefault
PDB boolean flag indicating whether this object should be considered for persistence
when persistence has not been specifically requested by calling ppid() or PDB addObjectToPersist.
Always false by default for Object.
slotDescriptionMap
Returns raw map of slot names and short values' descriptions.
See also Object slotSummary.
slotNames
Returns a list of strings containing the names of the
slots in the receiver (but not in its lookup path).
slotSummary
Returns a formatted
slotDescriptionMap.
Io> slotSummary
==> Object_0x30c590:
Lobby = Object_0x30c590
Protos = Object_0x30c880
exit = method(...)
forward = method(...)
slotValues
Returns a list of the values held in the slots of the receiver.
stopStatus
Returns the internal IoState->stopStatus.
super(aMessage)
Sends the message aMessage to the receiver's proto with the context of self. Example:
self test(1, 2) // performs test(1, 2) on self
super(test(1, 2)) // performs test(1, 2) on self proto but with the context of self
switch(, , , , ...)
Execute an expression depending on the value of the caller. (This is an equivalent to C switch/case)
hour := Date hour switch(
12, "midday",
0, "midnight",
17, "teatime",
Date hour asString
)
tailCall(expression)
Does a tailCall on the currently executing Block. Example:
Io> a := method(x, x = x + 1; if(x > 10, return x); tailCall(x))
==> method(x, updateSlot("x", x +(1));
if(x >(10), return(x));
tailCall(x))
Io> a(1)
==> 11
thisContext
Synonym to self.
thisLocalContext
Returns current locals.
thisMessage
Returns the calling message (i.e. thisMessage itself, huh).
try(code)
Executes particular code in a new coroutine.
Returns exception or nil if no exception is caught.
See also documentation for Exception catch and pass.
type
Returns a string containing the name of the type of Object (Number, String, etc).
uniqueHexId
Returns uniqueId in a hexadecimal form (with a "0x" prefix)
Io> Object uniqueId
==> 3146784
Io> Object uniqueHexId
==> 0x300420
uniqueId
Returns a Number containing a unique id for the receiver.
unpersist
PDB extension to populate this object with the data associated with this object's ppid from PDB.
updateSlot(slotNameString, valueObject)
Same as setSlot(), but raises an error if the slot does not
already exist in the receiver's slot lookup path.
wait(s)
Pauses current coroutine for at least s seconds.
Note: current coroutine may wait much longer than designated number of seconds
depending on circumstances.
while(, expression)
Keeps evaluating message until condition return Nil.
Returns the result of the last message evaluated or Nil if none were evaluated.
Sends a print message to the evaluated result of each argument. Returns Nil.
Same as write() but also writes a return character at the end. Returns Nil.
yield
Yields to another coroutine. Does nothing if yieldingCoros queue is empty.
See Coroutine documentation for more details.
Sequence
A Sequence is a container for a list of data elements. Typically these elements are each 1 byte in size. A Sequence can be either mutable or immutable. When immutable, only the read-only methods can be used.
Terminology
- Buffer: A mutable Sequence of single byte elements, typically in a binary encoding
- Symbol or String: A unique immutable Sequence, typically in a character encoding
*(aSeq)
Multiplies the values of aSeq to the corresponding values of the receiver
returning a new vector with the result.
Only works on Sequences whose item type is numeric.
*=(aSeq)
Multiplies the values of aSeq to the corresponding values of the receiver.
Only works on Sequences whose item type is numeric. Returns self.
+(aSeq)
Vector addition - Adds the values of aSeq to the corresponding values of the receiver
returning a new vector with the result.
Only works on Sequences whose item type is numeric.
+=(aSeq)
Vector addition - adds the values of aSeq to those of the receiver.
Only works on Sequences whose item type is numeric. Returns self.
-=(aSeq)
Vector subtraction - subtracts the values of aSeq to those of the receiver.
Only works on Sequences whose item type is numeric. Returns self.
..(aSequence)
Returns a copy of the receiver with aSequence appended to it.
/(aSeq)
Divides the values of aSeq to the corresponding values of the receiver
returning a new vector with the result.
Only works on Sequences whose item type is numeric.
/=(aSeq)
Divides the values of aSeq to the corresponding values of the receiver.
Only works on Sequences whose item type is numeric. Returns self.
Max
Returns the maximum value in the sequence.
Min
Returns the minimum value in the sequence.
abs
Sets each value of the Sequence to its absolute value.
Returns self.
acos
Sets each value of the Sequence to the trigonometric arcsine of it's value.
Returns self.
afterSeq(aSequence)
Returns the slice of the receiver (as a Symbol) after aSequence or
nil if aSequence is not found. If aSequence is empty, the receiver
(or a copy of the receiver if it is mutable) is returned.
alignCenter(width, [padding]) ""
Example:
Io> "abc" alignCenter(10, "-")
==> ---abc----
Io> "abc" alignCenter(10, "-=")
==> -=-abc-=-=
alignLeft(width, [padding])
Example:
Io> "abc" alignLeft(10, "+")
==> abc+++++++
Io> "abc" alignLeft(10, "-=")
==> abc-=-=-=-
alignLeftInPlace(width, [padding])
Same as align left but operation is performed on the receiver.
alignRight(width, [padding])
Example:
Io> "abc" alignRight(10, "-")
==> -------abc
Io> "abc" alignRight(10, "-=")
==> -=-=-=-abc
allMatchesOfRegex(aRegexOrString)
Returns a List containing all matches of the given regex found in the receiver.
append(aNumber)
Appends aNumber (cast to a byte) to the receiver. Returns self.
appendPathSeq(aSeq)
Appends argument to the receiver such that there is one
and only one path separator between the two. Returns self.
appendSeq(object1, object2, ...)
Calls asString on the arguments and appends the string to the receiver. Returns self.
asBase64(optionalCharactersPerLine)
Returns an immutable, base64 encoded (according to RFC 1421) version of self.
optionalCharactersPerLine describes the number of characters between line breaks and defaults to 0.
asBinaryNumber
Returns a Number containing the first 8 bytes of the
receiver without casting them to a double. Endian is same as machine.
asBinarySignedInteger
Returns a Number with the bytes of the receiver interpreted as a binary signed integer. Endian is same as machine.
asBinaryUnsignedInteger
Returns a Number with the bytes of the receiver interpreted as a binary unsigned integer. Endian is same as machine.
asCapitalized
Returns a copy of the receiver with the first charater made uppercase.
asFile
Returns a new File object with the receiver as its path.
asFixedSizeType
Returns a new sequence with the receiver encoded in the
minimal fixed width text encoding that its characters can fit
into (either, ascii, utf8, utf16 or utf32).
asHTML
SGML extension to interpret the Sequence as HTML and return an SGML object using SGMLParser elementForString
asHex
Returns a hex string for the receiving sequence, e.g., \"abc\" asHex -> \"616263\".")
asIoPath
Returns a Io style path for an OS style path.
asJid
Converts Sequence to JID object.
"cow@moo.com/Scandinavia" asJid
asJson
Converts to form that could be interpreted as json if it already contains json, e.g. {"aaa":"bbb"} --> "{\"aaa\":\"bbb\"}"
asLowercase
Returns a symbol containing the reveiver made lowercase.
asMessage(optionalLabel)
Returns the compiled message object for the string.
asMutable
Returns a mutable copy of the receiver.
asNumber
Returns the receiver converted to a number.
Initial whitespace is ignored.
asOSPath
Returns a OS style path for an Io style path.
asRegex
Returns a new Regex created from the receiver.
asSGML
SGML extension to interpret the Sequence as SGML and return an SGML object using SGMLParser elementForString
asStruct(memberList)
For a sequence that contains the data for a raw memory data structure (as used in C),
this method can be used to extract its members into an Object. The memberList argument
specifies the layout of the datastructure. Its form is:
list(memberType1, memberName1, memberType2, memberName2, ...)
Member types include:
int8, int16, int32, int64
uint8, uint16, uint32, uint64
float32, float64
Example:
pointObject := structPointSeq asStruct(list("float32", "x", "float32", "y"))
The output pointObject would contain x and y slots with Number objects.
asSymbol
Returns a immutable Sequence (aka Symbol) version of the receiver.
asUCS2
Returns a new copy of the receiver converted to UCS2 (fixed character width UTF16) encoding.
asUCS4
Returns a new copy of the receiver converted to UCS4 (fixed character width UTF32) encoding.
asURL
Returns a new URL object instance with the receiver as its url string.
asUTF8
Returns a new copy of the receiver converted to utf8 encoding.
asUppercase
Returns a symbol containing the reveiver made uppercase.
asUrl
Shortcut for HCUrl with(aUrlSeq)
asXML
SGML extension to interpret the Sequence as XML and return an SGML object using SGMLParser elementForString
asin
Sets each value of the Sequence to the trigonometric arcsine of it's value.
Returns self.
at(aNumber)
Returns a value at the index specified by aNumber.
Returns nil if the index is out of bounds.
atInsertSeq(indexNumber, object)
Calls asString on object and inserts the string at position indexNumber. Returns self.
atPut(aNumberIndex, aNumber)
Sets the value at the index specified by aNumberIndex to aNumber. Returns self.
atan
Sets each value of the Sequence to the trigonometric arctangent of it's value.
Returns self.
beforeSeq(aSequence)
Returns the slice of the receiver (as a Symbol) before
aSequence or self if aSequence is not found.
beginsWithSeq(aSequence)
Returns true if the receiver begins with aSequence, false otherwise.
betweenSeq(aSequence, anotherSequence)
Returns a new Sequence containing the bytes between the
occurrence of aSequence and anotherSequence in the receiver.
If aSequence is empty, this method is equivalent to beforeSeq(anotherSequence).
If anotherSequence is nil, this method is equivalent to afterSeq(aSequence).
nil is returned if no match is found.
bitAt(bitIndex)
Returns a Number containing the bit at the bit index value.
bitCount
Returns the number of bits in the sequence.
bitwiseAnd(aSequence)
Updates the receiver to be the result of a bitwiseAnd with aSequence. Returns self.
bitwiseNot(aSequence)
Updates the receiver to be the result of a bitwiseNot with aSequence. Returns self.
bitwiseOr(aSequence)
Updates the receiver to be the result of a bitwiseOr with aSequence. Returns self.
bitwiseXor(aSequence)
Updates the receiver to be the result of a bitwiseXor with aSequence. Returns self.
byteAt(byteIndex)
Returns a Number containing the byte at the byte index value.
capitalize
First charater of the receiver is made uppercase.
ceil
Round each value to smallest integral value not less than x.
Returns self.
clear
Set all values in the sequence to 0. Returns self.
clipAfterSeq(aSequence)
Removes the contents of the receiver after the end of
the first occurance of aSequence. Returns true if anything was
removed, or false otherwise.
clipAfterStartOfSeq(aSequence)
Removes the contents of the receiver after the beginning of
the first occurance of aSequence. Returns true if anything was
removed, or false otherwise.
clipBeforeEndOfSeq(aSequence)
Removes the contents of the receiver before the end of
the first occurance of aSequence. Returns true if anything was
removed, or false otherwise.
clipBeforeSeq(aSequence)
Clips receiver before aSequence.
cloneAppendPath(aSequence)
Appends argument to a copy the receiver such that there is one
and only one path separator between the two and returns the result.
contains(aNumber)
Returns true if the receiver contains an element equal in value to aNumber, false otherwise.
containsAnyCaseSeq(aSequence)
Returns true if the receiver contains the aSequence
regardless of casing, false otherwise.
containsSeq(aSequence)
Returns true if the receiver contains the substring
aSequence, false otherwise.
convertToItemType(aTypeName)
Converts the underlying machine type for the elements, expanding or contracting
the size of the Sequence as needed.
Valid names are uint8, uint16, uint32, uint64, int8, int16, int32,
int64, float32, and float64. Note that 64 bit types are only available
on platforms that support such types. Returns self.
copy(aSequence)
Replaces the bytes of the receiver with a copy of those in aSequence. Returns self.
cos
Sets each value of the Sequence to the trigonometric cosine of it's value.
Returns self.
cosh
Sets each value of the Sequence to the hyperbolic cosine of its value.
Returns self.
distanceTo(aSeq)
Returns a number with the square root of the sum of the square
of the differences of the items between the sequences.
dotProduct(aSeq)
Returns a new Sequence containing the dot product of the receiver with aSeq.
duplicateIndexes
Duplicates all indexes in the receiver.
For example, list(1,2,3) duplicateIndexes == list(1,1,2,2,3,3). Returns self.
empty
Sets all bytes in the receiver to 0x0 and sets
its length to 0. Returns self.
encoding
Returns the encoding of the elements.
endsWithSeq(aSequence)
Returns true if the receiver ends with aSequence, false otherwise.
escape
Escape characters in the receiver are replaced with escape codes.
For example a string containing a single return character would contain the
following 2 characters after being escaped: "\n". Returns self.
escapeRegexChars
Returns a clone of the receiver with all special regular expression characters
("^", "$", etc) backslashed. Useful if you have a string that contains such characters,
but want it to be treated as a literal string.
exclusiveSlice(inclusiveStartIndex, exclusiveEndIndex)
Returns a new string containing the subset of the
receiver from the inclusiveStartIndex to the exclusiveEndIndex. The exclusiveEndIndex argument
is optional. If not given, it is assumed to be one beyond the end of the string.
exp
Sets each value of the Sequence to e**value.
Returns self.
fileName
Returns the last path component sans the path extension.
findNthSeq(aSequence, n)
Returns a number with the nth occurence of aSequence.
findRegex(aRegexOrString, [startIndex])
Returns the first match of the given regex in the receiver, after the given start index.
If you don't specify a start index, the search will start at the beginning of the receiver.
The method returns nil if no match is found.
findSeq(aSequence, optionalStartIndex)
Returns a number with the first occurrence of aSequence in
the receiver after the startIndex. If no startIndex is specified,
the search starts at index 0.
nil is returned if no occurences are found.
findSeqs(listOfSequences, optionalStartIndex)
Returns an object with two slots - an \"index\" slot which contains
the first occurrence of any of the sequences in listOfSequences found
in the receiver after the startIndex, and a \"match\" slot, which
contains a reference to the matching sequence from listOfSequences.
If no startIndex is specified, the search starts at index 0.
nil is returned if no occurences are found.
floor
Round each value to largest integral value not greater than x.
Returns self.
foreach(optionalIndex, value, message)
For each element, set index to the index of the
element and value to the element value and execute message.
Example:
aSequence foreach(i, v, writeln("value at index ", i, " is ", v))
aSequence foreach(v, writeln("value ", v))
fromBase(aNumber)
Returns a number with a base 10 representation of the receiver
converted from the specified base. Only base 2 through 32 are currently supported.
fromBase64
Returns an immutable, base64 decoded (according to RFC 1421) version of self.
greaterThan(aSeq)
Returns true if the receiver is greater than aSeq, false otherwise.
greaterThanOrEqualTo(aSeq)
Returns true if the receiver is greater than or equal to aSeq, false otherwise.
hasMatchOfRegex(aRegexOrString)
Returns true if the string contains one or more matches of the given regex.
hash
Returns a Number containing a hash of the Sequence.
inclusiveSlice(inclusiveStartIndex, inclusiveEndIndex)
Returns a new string containing the subset of the
receiver from the inclusiveStartIndex to the inclusiveEndIndex. The inclusiveEndIndex argument
is optional. If not given, it is assumed to be the end of the string.
interpolate(ctx)
Returns immutable copy of self with interpolateInPlace(ctx) passed to the copy.
interpolateInPlace(optionalContext)
Replaces all #{expression} with expression evaluated in the optionalContext.
If optionalContext not given, the current context is used. Returns self.
isEmpty
Returns true if the size of the receiver is 0, false otherwise.
isEqualAnyCase(aSequence)
Returns true if aSequence is equal to the receiver
ignoring case differences, false otherwise.
isLowercase
Returns self if all the characters in the string are lower case.
isMutable
Returns true if the receiver is a mutable Sequence or false otherwise.
isSymbol
Returns true if the receiver is a
immutable Sequence (aka, a Symbol) or false otherwise.
isUppercase
Returns self if all the characters in the string are upper case.
isZero
Returns true if all elements are 0, false otherwise.
itemCopy
Returns a new sequence containing the items from the receiver.
itemSize
Returns number of bytes in each element.
itemType
Returns machine type of elements.
justSerialized(stream)
Writes the receiver's code into the stream.
lastPathComponent
Returns a string containing the receiver clipped up
to the last path separator.
lessThan(aSeq)
Returns true if the receiver is less than aSeq, false otherwise.
lessThanOrEqualTo(aSeq)
Returns true if the receiver is less than or equal to aSeq, false otherwise.
linePrint
Prints the Sequence and a newline character.
log
Sets each value of the Sequence to the natural log of its value.
Returns self.
log10
Sets each value of the Sequence to the base 10 log of its value.
Returns self.
logicalAnd(aSequence)
Updates the receiver's values to be the result of a logical OR operations with the values of aSequence. Returns self.
logicalOr(aSequence)
Updates the receiver's values to be the result of a logical OR operations with the values of aSequence. Returns self.
lowercase
Makes all the uppercase characters in the receiver lowercase. Returns self.
lstrip(aSequence)
Strips the characters in aSequence
stripped from the beginning of the receiver. Example:
"Keep the tail" lstrip(" eKp")
==> "the tail"
makeFirstCharacterLowercase
Receiver must be mutable (see also asMutable). Returns receiver.
Io> "ABC" asMutable makeFirstCharacterLowercase
==> aBC
makeFirstCharacterUppercase
Receiver must be mutable (see also asMutable). Returns receiver.
Io> "abc" asMutable makeFirstCharacterUppercase
==> Abc
matchesOfRegex(aRegexOrString)
Returns a RegexMatches object that enumerates all matches of the given regex in the receiver.
matchesRegex(aRegexOrString)
Returns true if the receiver matches the given regex, false if not.
max
Returns the maximum value of the Sequence.
mean
Returns the arithmetic mean of the sequence.
meanSquare
Returns the arithmetic mean of the sequence's values after they have been squared.
min
Returns the minimum value of the Sequence.
negate
Negates the values of the receiver.
Returns self.
normalize
Divides each value of the Sequence by the max value of the sequence.
Returns self.
occurancesOfSeq(aSeq)
Returns count of aSeq in the receiver.
pathComponent
Returns a slice of the receiver before the last path separator as a symbol.
pathExtension
Returns a string containing the receiver clipped up to the last period.
preallocateToSize(aNumber)
If needed, resize the memory alloced for the receivers
byte array to be large enough to fit the number of bytes specified by
aNumber. This is useful for pio_reallocating the memory so it doesn't
keep getting allocated as the Sequence is appended to. This operation
will not change the Sequence's length or contents. Returns self.
prependSeq(object1, object2, ...)
Prepends given objects asString in reverse order to the receiver. Returns self.")
print
Prints contents of a sequence.
product
Returns the product of all the sequence's values multipled together.
rangeFill
Sets the values of the Sequence to their index values.
Returns self.
removeAt(index)
Removes the item at index. Returns self.
removeEvenIndexes
Removes even indexes in the receiver.
For example, list(1,2,3) removeEvenIndexes == list(1, 3). Returns self.
removeLast
Removes the last element from the receiver. Returns self.
removeOddIndexes
Removes odd indexes in the receiver.
For example, list(1,2,3) removeOddIndexes == list(2). Returns self.
removePrefix(aSequence)
If the receiver begins with aSequence, it is removed. Returns self.
removeSeq(aSequence)
Removes occurances of aSequence from the receiver.
removeSlice(startIndex, endIndex)
Removes the items from startIndex to endIndex.
Returns self.
removeSuffix(aSequence)
If the receiver end with aSequence, it is removed. Returns self.
repeated(n)
Returns a new sequence containing the receiver repeated n number of times.
replaceFirstSeq(aSequence, anotherSequence, optionalStartIndex)
Returns a new Sequence with the first occurance of aSequence
replaced with anotherSequence in the receiver. If optionalStartIndex is
provided, the search for aSequence begins at that index. Returns self.
replaceMap(aMap)
In the receiver, the keys of aMap replaced with its values. Returns self.
replaceSeq(aSequence, anotherSequence)
Returns a new Sequence with all occurances of aSequence
replaced with anotherSequence in the receiver. Returns self.
reverse
Reverses the ordering of all the items of the receiver. Returns copy of receiver.
reverseFindSeq(aSequence, startIndex)
Returns a number with the first occurrence of aSequence in
the receiver before the startIndex. The startIndex argument is optional.
By default reverseFind starts at the end of the string. Nil is
returned if no occurrences are found.
reverseInPlace
Reverses the bytes in the receiver, in-place.
rstrip(aSequence)
Strips the characters in
aSequence stripped from the end of the receiver. Example:
"Cut the tail off" rstrip(" afilot")
==> "Cut the"
set(aNumber1, aNumber2, ...)
Sets the values of the receiver to the sequences of numbers in the arguments.
Unset values will remain unchanged.
Returns self.
setEncoding(encodingName)
Sets the encoding flag of the receiver (only the encoding flag,
itemSize and itemType will change, no conversion is done between UTF
encodings - you can use convertToUTF8, etc methods for conversions).
Valid encodings are number, utf8, utf16, and utf32. Returns self.
setItemType(aTypeName)
Sets the underlying machine type for the elements.
Valid names are uint8, uint16, uint32, uint64, int8, int16, int32,
int64, float32, and float64. Note that 64 bit types are only available
on platforms that support such types. Returns self.
setItemsToDouble(aNumber)
Sets all items in the Sequence to the double floating point value of aNumber.
setItemsToLong(aNumber)
Sets all items in the Sequence to the long integer value of aNumber.
setSize(aNumber)
Sets the length in bytes of the receiver to aNumber. Return self.
sin
Sets each value of the Sequence to the trigonometric sine of it's value.
Returns self.
sinh
Sets each value of the Sequence to the hyperbolic sine of its value.
Returns self.
size
Returns the length in number of items (which may or may not
be the number of bytes, depending on the item type) of the receiver. For example,
"abc" size == 3
sizeInBytes
Returns the length in bytes of the receiver.
slice
Deprecated method. Use exSlice instead.
slicesBetween(startSeq, endSeq)
Returns a list of slices delimited
by
startSeq and
endSeq.
Io> "" slicesBetween("<", ">")
==> list("a", "b", "/b", "/a")
sort
Sorts the characters/numbers in the array. Returns self.
split Returns a list containing the sub-sequences of the receiver divided by the given arguments.
If no arguments are given the sequence is split on white space.
split(optionalArg1, optionalArg2, ...)
Returns a list containing the sub-sequences of the receiver divided by the given arguments.
If no arguments are given the sequence is split on white space.
Examples:
"a b c d" split == list("a", "b", "c", "d")
"a*b*c*d" split("*") == list("a", "b", "c", "d")
"a*b|c,d" split("*", "|", ",") == list("a", "b", "c", "d")
"a b c d" split == list("a", "", "", "", "b", "", "", "c", "", "d")
splitAt(indexNumber)
Returns a list containing the two parts of the receiver as split at the given index.
splitAtRegex(aRegexOrString)
Splits the receiver into pieces using the given regex as the delimiter and
returns the pieces as a list of strings.
splitNoEmpties(optionalArg1, optionalArg2, ...)
Returns a list containing the non-empty sub-sequences of the receiver divided by the given arguments.
If no arguments are given the sequence is split on white space.
Examples:
"a b c d" splitNoEmpties => list("a", "b", "c", "d")
"a***b**c*d" splitNoEmpties("*") => list("a", "b", "c", "d")
"a***b||c,d" splitNoEmpties("*", "|", ",") => list("a", "b", "c", "d")
sqrt
Sets each value of the Sequence to the square root of its value.
Returns self.
square
Sets each value of the Sequence to the square of its value.
Returns self.
strip(optionalSequence)
Trims the whitespace (or optionalSequence) off both ends:
" Trim this string \r\n" strip
==> "Trim this string"
sum
Returns the sum of the Sequence.
tan
Sets each value of the Sequence to the trigonometric tangent of it's value.
Returns self.
tanh
Sets each value of the Sequence to the hyperbolic tangent of its value.
Returns self.
toBase(aNumber)
Returns a Sequence containing the receiver (which is
assumed to be a base 10 number) converted to the specified base.
Only base 8 and 16 are currently supported.
translate(fromChars, toChars)
In the receiver, the characters in fromChars are replaced with those in the same positions in toChars. Returns self.
unescape
Escape codes replaced with escape characters. Returns self.
uppercase
Makes all characters of the receiver uppercase.
whiteSpaceStrings
Returns a List of strings. Each string contains a different
whitespace character.
with(aSequence, ...)
Returns a new Sequence which is the concatination of the arguments.
The returned sequence will have the same mutability status as the receiver.
withStruct(memberList)
This method is useful for producing a Sequence containing a raw datastructure with
the specified types and values. The memberList format is:
list(memberType1, memberName1, memberType2, memberName2, ...)
Member types include:
int8, int16, int32, int64
uint8, uint16, uint32, uint64
float32, float64
Example:
pointStructSeq := Sequence withStruct(list("float32", 1.2, "float32", 3.5))
The output pointStructSeq would contain 2 raw 32 bit floats.