Jess71p2 20 - and rules. 3.6. Calling functions As in Lisp,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3. Jess Language Basics 12 There" The last string is equivalent to the Java string "Hello,\nThere". 3.4. Lists Another fundamental unit of syntax in Jess is the list. A list always consists of an enclosing set of parentheses and zero or more symbols, numbers, strings, or other lists. The following are valid lists: (+ 3 2) (a b c) ("Hello, World") () (deftemplate foo (slot bar)) The first element of a list (the car of the list in Lisp parlance) is often called the list's head in Jess. 3.5. Comments Jess supports two kinds of programmer's comments: Lisp-style line comments and C-style block comments. Line comments begin with a semicolon ( ; ) and extend to the end of the line of text. Here is an example of a line comment: ; This is a list (a b c) Block comments work as they do in C: they start with the two characters "/*" and end with "*/". Block comments don't nest. /* Here is an example of a list (commented out): (a b c) */ Comments can appear anywhere in a Jess program, including inside constructs like templates
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: and rules. 3.6. Calling functions As in Lisp, all code in Jess ( control structures , assignments , procedure calls) takes the form of a function call. There are no "operators"; everything is a function call. However, some functions have names that look like Java operators, and in these cases, they operate much like their Java counterparts. Function calls in Jess are simply lists . Function calls use a prefix notation; a list whose head is a symbol that is the name of an existing function can be a function call. For example, an expression that uses the + function to add the numbers 2 and 3 would be written (+ 2 3) . When evaluated, the value of this expression is the number 5 (not a list containing the single element 5 !). In general, expressions are recognized as such and evaluated in context when appropriate. You can type expressions at the Jess> prompt. Jess evaluates the expression and prints the result: Jess> (+ 2 3) 5 Jess> (+ (+ 2 3) (* 3 3)) 14...
View Full Document

This note was uploaded on 03/02/2010 for the course COMP 102 taught by Professor Smith during the Spring '10 term at California State University , Monterey Bay.

Ask a homework question - tutors are online