CGOL - Syntax

Syntax

Special notations are available for many commonly used MACLISP operations. For example, one can write a matrix multiply routine as:

for i in 1 to n do for k in 1 to n do (ac := 0; for j in 1 to n do ac := ac + a(i,j)*b(j,k); c(i,k) := ac)

CGOL has an infix . operation (referring to MACLISP's cons function) and the infix @ operation (referring to MACLISP's append function):

a.(b@c) = (a.b)@c

The preceding example corresponds to this text in native MACLISP:

(EQUAL (CONS A (APPEND B C)) (APPEND (CONS A B) C))

CGOL uses of to read and set properties:

'father' of x := 'brother' of relative of y

The preceding example corresponds to this text in native MACLISP:

(PUTPROP X (GET (GET Y RELATIVE) 'BROTHER) 'FATHER)

This illustrates how CGOL notates a function of two arguments:

\x,y; 1/sqrt(x**2 + y**2)

The preceding example corresponds to this text in native MACLISP:

(LAMBDA (X Y) (QUOTIENT 1 (SQRT (PLUS (EXPT X 2) (EXPT Y 2)))))

The syntax of CGOL is data-driven and so both modifiable and extensible.

Read more about this topic:  CGOL