How do I create, expand, and shrink lists in transcendence?
I want to create ships and put pointers to the ships in a list using a for loop.
I also want to take this further. I want to create several lists as above and put them into another list.
Is it just like in the lisp tutorials that I've found on the web?
expanding, shrinking and creating lists in transcedence
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
I don't know about the tutorials, none of the tuts I found ever worked well in Transcendence Lisp.
Sounds like you need something like:
which creates a list of lists. The list is called activeEventList, which contains lists holding some data (timeStamp1, message text, functionName)
you can create a list by simply setting up a (setq listName (list item1 item2 item3))
Check out the Functions section on Xelerus for more list functions.
Also this thread: storing lists on gPlayerShip
Sounds like you need something like:
Code: Select all
(block (eventOne)
(setq eventOne (list (list timeStamp1 "Event Manager is Operating" tmrNada)))
(objSetData gPlayerShip "activeEventList" eventOne)
)
you can create a list by simply setting up a (setq listName (list item1 item2 item3))
Check out the Functions section on Xelerus for more list functions.
Also this thread: storing lists on gPlayerShip
not really, I need something like this:
cons is a list function that I found on the tutorials.
Code: Select all
(for x 0 4 ; 4 could be changed to 5, 100, or any other integer
(block Nil
(setq ship (sysCreateShip &scPhobos; gPlayerShip &svAres;)
(setq listofships (cons ship listofships)
)
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
you found it on the tutorials... I found lots of Lisp functions that George hasn't added into the TransLisp. Remember- it's Lisp-like not Lisp.
So, does 'cons' work in transcendence?
edit- seems like it doesn't.
the working list functions:
append
count
enum
enumwhile
item
list
lnkAppend
lnkRemove
lnkRemoveNil
lnkReplace
So, does 'cons' work in transcendence?
edit- seems like it doesn't.
the working list functions:
append
count
enum
enumwhile
item
list
lnkAppend
lnkRemove
lnkRemoveNil
lnkReplace
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
can you describe what cons does? We might be able to make it in code.
Crying is not a proper retort!
- Periculi
- Fleet Officer
- Posts: 1282
- Joined: Sat Oct 13, 2007 7:48 pm
- Location: Necroposting in a forum near you
From EMacs Lisp intro tutorialThe cons function constructs lists; it is the inverse of car and cdr. For example, cons can be used to make a four element list from the three element list, (fir oak maple):
(cons 'pine '(fir oak maple))
After evaluating this list, you will see
(pine fir oak maple)
appear in the echo area. cons puts a new element at the beginning of a list; it attaches or pushes elements onto the list.
Which makes it similar to the lnkAppend, except it places the item at the beginning of the list.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
so it would be
Code: Select all
(setq cons (lamba (myatom mylist)
(append (list myatom) mylist)
))
Crying is not a proper retort!
-
- Developer
- Posts: 2998
- Joined: Thu Jul 24, 2003 9:53 pm
- Contact:
I think it might be easier than that:
(which probably means that I should rename append...or at least create a synonym)
Code: Select all
(setq cons append)
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
append appends lists together and I guess if one of those lists is not a list it makes it a list then appends it.
(append 'a '(b c d))
has the same result as
(append '(a) '(b c d))
and that is the list (a b c d)
(append 'a '(b c d))
has the same result as
(append '(a) '(b c d))
and that is the list (a b c d)
Crying is not a proper retort!
no, it doesn't matter whether it places it at the beginning or the end. I should be able to use lnkRemove to shrink lists, so that pretty much answers all my problems.
Last edited by F50 on Sat Mar 29, 2008 5:13 am, edited 1 time in total.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
after a few more tests I found that append is very powerful and lnkAppend is useless. 8)
(append 'a 'b) gives you the list (a b)
(append '(a b c) 'd) gives you the list (a b c d)
(append 'a 'b) gives you the list (a b)
(append '(a b c) 'd) gives you the list (a b c d)
Crying is not a proper retort!
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
well not useless just redundant (append can do anything lnkAppend can do easily but lnkAppend can not do the stuff that append can do easily)
Crying is not a proper retort!