Differences between version 4 and previous revision of GCBot.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 4 | Last edited on Thursday, December 2, 2004 3:25:45 pm | by CraigBox | Revert |
Older page: | version 1 | Last edited on Thursday, December 2, 2004 1:22:58 am | by PerryLorier | Revert |
@@ -1,23 +1,23 @@
-GCBot is an [IRC] bot that [Isomer] made to see what happens if you give a bunch of programmers a shared programming environment (IRC) and what happens.
+GCBot is an [IRC] bot that [Isomer|PerryLorier
] made to see what happens if you give a bunch of programmers a shared programming environment (IRC) and what happens.
GCBot's programming language is very simple, everything is either a symbol, a function call, a list, a string or a number.
The grammer is very simple:
<literal>::= "string"
| 'string'
- | [-9]\.[-9]
+ | [
[-9]\.[
[-9]
- <symbol> ::= [^,()\[\]]
+ <symbol> ::= [
[^,()\[
[\]]
<comma-expression> ::= <expression>
| <expression> ',' <comma-expression>
<symbol-or-literal> ::= <symbol>
| <literal>
- <term> ::= '[' <comma-expression> ']'
+ <term> ::= '[
[' <comma-expression> ']'
| <symbol-or-literal>
<expression> ::= <term>
| <term> '(' <comma-expression ')'
@@ -40,9 +40,9 @@
!!apply(''expression'',''list of arguments'')
Calls ''expression'' with ''arguments''.
eg:
- apply(+,[1,2,3])
+ apply(+,[
[1,2,3])
!!at(''list'',''expression'')
Returns the ''expression''th item in ''list''
@@ -51,13 +51,13 @@
!!decompose(''functioncall'')
Returns a list of the head of the function call, a the list of the arguments.
eg:
- decompose(+(1,2,3)) => [+,[1,2,3]]
+ decompose(+(1,2,3)) => [
[+,[
[1,2,3]]
!!define(''name'',''vars'',''expression'')
This works like lambda, however it also binds it to a name. define could have been implemented as:
- lambda([name,vars,expression],set(name,lambda(vars,expression)))
+ lambda([
[name,vars,expression],set(name,lambda(vars,expression)))
!!head(''list'')
Returns the first item of list.
@@ -65,11 +65,11 @@
This function evaluates cond, then evaluates either true or false depending on the result of cond. Anything that isn't 0 is considered true.
!!lambda(''vars'',''expression'')
Takes a list of variables, and when called replaces each variable with it's corresponding positional argument everywhere in the expression. For example:
- lambda([a,b],+(a,b))
+ lambda([
[a,b],+(a,b))
will create an anonymous function that takes two arguments (a and b) and returns their sum. eg:
- lambda([a,b],+(a,b))(1,2) => 3
+ lambda([
[a,b],+(a,b))(1,2) => 3
beaware that the bindings of lambda's variables can be cached, so if a function can return different values every time it's called, you may end up with some unexpected results.
!!now()
Returns the number of seconds since 1970-01-01. Beaware that this function changes it's result everytime you call it, and may interact badly with lambda's primative caching.
@@ -91,5 +91,5 @@
!!undef(''name'')
Unbinds name, returning the previous expression that name was bound to.
eg:
- define(rename,[old,new],set(new,undef(old)))
+ define(rename,[
[old,new],set(new,undef(old)))