fun with enumeration

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

there are for basic enumeration or looping functions in Transcendence but there is only one needed and that is loop.

(loop conditional function)
A loop works like this.
First you check the conditional if false go to the code after the loop.
If true run the function.
Go to the conditional.

Now that we know how the loop works then lets make the other kind of loop.

(enum mylist variable function)

Not too hard just have a extra variable. index

Code: Select all

(setq index 0)
(setq listSize (count myList))
(loop (ls index listSize)
	(setq variable (item myList index))
	;put the function here
	(setq index (add index 1))
)
(enumwhile list condition variable function)

Nearly the same as enum but has an extra condition.

Code: Select all

(setq index 0)
(setq listSize (count myList))
(loop (and (ls index listSize) condition)
	(setq variable (item myList index))
	;put the function here
	(setq index (add index 1))
)
(for variable startNumber endNumber function)

For is simpler than the others.

Code: Select all

(setq index startIndex)
(loop (leq index endIndex)
	(setq variable index)
	;put the function here
	(setq index (add index 1))
)
And for a bonus while not in transcendence many have a do while. Basically think of a loop that has the conditional at the bottom instead of the top.

Code: Select all

(setq runOnce True)
(loop (or runOnce conditional)
	;put the function here
	(setq runOnce nil)
)
Any questions or comments?
Crying is not a proper retort!
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

best tutorial ever ! :shock:

now finally i have examples of loop and a way to understand the other iterating functions !

probably i can make a loop now without using a variable to break the loop as the only conditional (that is not elegant and I know you don't like it) :D
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

probably i can make a loop now without using a variable to break the loop as the only conditional (that is not elegant and I know you don't like it)
That isn't exactly true there are situations that that is exactly what you want to do. For transcendence though most of the time you do not need anything like that.
Crying is not a proper retort!
Post Reply