symbol Specification Sheet


Computer Algebra Kit (c) 1993,97 by Comp.Alg.Objects. All Rights Reserved.

Symbol

Inherits from:CAObject

Class Description

Maturity Index : Relatively Mature

For symbols created with the factory method newStrValue:, the first character of the strValue of the symbol object must be a letter. Subsequent characters can be letters or digits. Whitespace or control characters are not allowed.

Using the factory method newChars:count:, it's possible to use arbitrary C strings as the value of the symbol; in this case Symbol just acts like a regular Objective C String class. If you intend to use the object as a mathematical symbol, it's not advised to do this as you might incorrectly interpret spaces etc. as mathematical operators.

Method Types

Creation

Identity

Expression Object

Printing

Methods



newStrValue:

+ newStrValue :(STR) aString

Creates a new symbol, and sets its value to a copy of aString. Returns nil if aString is not suited as value for a symbol (when the first letter is not a letter, for instance).



newChars:count:

+ newChars :(char *) aBuffer count :(int) numChars

Creates a new symbol, and sets its value to a copy of the first numChars characters of aBuffer. For this method, there are no restrictions on the C string being used.



copy

- copy

Returns a new symbol object. Copies the string.



deepCopy

- deepCopy

Equivalent to copy.



clear

- clear

Frees the memory for the string value.



strValue

- (STR) strValue

Returns the string value of the symbol. The first character is a letter, subsequent characters can be alphanumeric.



strValue:

- strValue :(STR) aString

Creates a new symbol, and sets its value to a copy of aString. Returns nil if aString is not suited as value for a symbol.



hash

- (unsigned) hash

Returns a hash value based upon the string.



isEqual:

- (BOOL) isEqual : b

Returns YES if the strValue's of both objects are equal.



compare:

- (int) compare : b

Compares the strValue's of both objects.



isLetter

- (BOOL) isLetter

Whether the symbol consists of just one character (and hence, is a letter, not a digit).



asExpression

- asExpression

Returns an expression object containing a copy of the symbol.



printToFile:

- printToFile :(FILE *) aFile

Prints the symbol to aFile.