ReLogo Utility (Groovy) class.
Type Params | Return Type | Name and description |
---|---|---|
|
static void |
beep() Sounds an audible tone. |
|
static String |
capitalize(String s) Capitalizes a string. |
|
static void |
checkAndSetWritable() |
|
static void |
dressClosure() |
|
static boolean |
fileAtEndQ() Queries if at end of the file. |
|
static void |
fileClose() Closes a file. |
|
static void |
fileCloseAll() Closes all files. |
|
static void |
fileDelete(String string) Deletes a file. |
|
static boolean |
fileExistsQ(String string) Queries if the file exists. |
|
static void |
fileFlush() Writes the file to disk. |
|
static void |
fileOpen(String string) Opens a file. |
|
static void |
filePrint(Object value) Prints a value to the current file with a newline. |
|
static def |
fileRead() Returns the next value from the current file. |
|
static String |
fileReadCharacters(int number) Returns a number of characters from the current file. |
|
static String |
fileReadLine() Returns the next line from the current file. |
|
static void |
fileShowU(String id, Object value) Prints value with agent identifier to current file with a newline. |
|
static void |
fileType(Object value) Prints value to current file without a newline. |
|
static void |
fileWrite(Object value) Writes a value to the current file so that fileRead can subsequently read it. |
<E> |
static Collection<E> |
filter(Closure closure, Collection<E> a) Returns a list filtered by a closure. |
|
static void |
foreach(Closure commands, Collection c) Executes a set of commands for each item in a collection. |
|
static void |
foreach(Closure commands, List... lists) Executes a set of commands for each slice of items across the lists. |
|
static Collection |
gflatten(Collection c) |
|
static def |
ifelseValue(Closure conditional, Closure closure1, Closure closure2) Returns the value of the first or second set of commands depending on the conditional. |
|
static ArrayList |
list(Object... args) Returns a list of items. |
|
static Collection |
map(Closure commands, Collection c) Executes a set of commands for each item in a collection and returns the resulting collection. |
|
static ArrayList |
map(Closure commands, List... lists) Executes a set of commands for each slice of items across the lists and returns the results. |
|
static List |
modes(Collection c) Returns the mode(s) of a collection of numbers. |
|
static void |
print(Object value) Prints an object. |
|
static def |
readFromString(String string) Interprets a string and returns the value. |
<E> |
static E |
reduce(Closure closure, List<E> list) Returns a reduced list by repeatedly applying a closure to pairs of inputs. |
|
static void |
runU(String string, Object o) Interprets a string as commands then runs the commands using an object's bindings. |
|
static Object |
runresultU(String string, Object o) Interprets a string as a command using an object's bindings then returns the result. |
|
static void |
setCurrentDirectory(String string) Sets the current directory to string. |
|
static void |
showU(String id, Object value) Prints value in the Console, preceded by the calling agent, and followed by a carriage return. |
<E> |
static List<E> |
sortBy(Closure closure, Collection<E> c) Returns a list sorted by a closure. |
|
static void |
type(Object value) Prints a value to the console without a newline. |
|
static String |
userDirectory() Allows the user to choose a user directory and returns the directory path. |
|
static String |
userFile() Allows the user to choose a user file and returns the file path. |
|
static String |
userInput(Object value) Returns a value that the user enters. |
|
static void |
userMessage(Object value) Displays a message to the user. |
|
static String |
userNewFile() Returns a new file chosen by the user. |
|
static Object |
userOneOf(Object value, Object[] list) Returns an object that the user chose from a list. |
|
static boolean |
userYesOrNoQ(Object value) Queries for user's answer to a question. |
|
static void |
write(Object value) Writes a value (enclosed in quotes) to the console without a newline. |
Sounds an audible tone.
Capitalizes a string.
s
- a stringQueries if at end of the file.
Closes a file.
Closes all files.
Deletes a file.
string
- a stringQueries if the file exists.
string
- a string pathWrites the file to disk.
Opens a file.
string
- a string pathPrints a value to the current file with a newline.
value
- an objectReturns the next value from the current file.
Returns a number of characters from the current file.
number
- an integerReturns the next line from the current file.
Prints value with agent identifier to current file with a newline.
id
- a stringvalue
- any objectPrints value to current file without a newline.
value
- any objectWrites a value to the current file so that fileRead can subsequently read it.
value
- any objectReturns a list filtered by a closure.
closure
- boolean closurea
- a collectionExecutes a set of commands for each item in a collection.
commands
- a set of commandsc
- a collectionExecutes a set of commands for each slice of items across the lists.
commands
- a set of commandslists
- a list of listsReturns the value of the first or second set of commands depending on the conditional.
conditional
- a boolean closureclosure1
- a closure returning a valueclosure2
- a closure returning a valueReturns a list of items.
args
- any number of itemsExecutes a set of commands for each item in a collection and returns the resulting collection.
commands
- a set of commandsc
- a collectionExecutes a set of commands for each slice of items across the lists and returns the results.
commands
- a set of commandslists
- a list of listsReturns the mode(s) of a collection of numbers.
c
- a collection of numbersPrints an object.
value
- an objectInterprets a string and returns the value.
string
- a stringReturns a reduced list by repeatedly applying a closure to pairs of inputs. e.g., reduce({a, b -> a * b }, [3, 1, 3, 2]) results in (((3 * 1) * 3) * 2)
closure
- a commandlist
- a listInterprets a string as commands then runs the commands using an object's bindings.
string
- a stringo
- an objectInterprets a string as a command using an object's bindings then returns the result.
string
- a stringo
- an objectSets the current directory to string.
string
- a stringPrints value in the Console, preceded by the calling agent, and followed by a carriage return. (The calling agent is included to help you keep track of what agents are producing which lines of output.) Also, all strings have their quotes included similar to write.
Returns a list sorted by a closure. The closure can be a single parameter closure, in which case the value returned is used to order the entities in ascending order. The closure can also have two parameters, in which case returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. See also: http://groovy.codehaus.org/groovy-jdk/java/util/Collection.html#sort(groovy.lang.Closure) e.g., ["a","abc","ab"].sort { a -> a.length() } or ["a","abc","ab"].sort { a,b -> a.length() <=> b.length() } both yield ["a","ab","abc"]
closure
- closure taking one or two argumentsc
- a collectionPrints a value to the console without a newline.
value
- any objectAllows the user to choose a user directory and returns the directory path.
Allows the user to choose a user file and returns the file path.
Returns a value that the user enters.
value
- the title of the dialog screenDisplays a message to the user.
value
- messageReturns a new file chosen by the user.
Returns an object that the user chose from a list.
value
- messagelist
- listQueries for user's answer to a question.
value
- questionWrites a value (enclosed in quotes) to the console without a newline.
value
- an object