Other ways to pass variable by reference
Posted: Thu Jan 28, 2010 7:11 pm
I`m trying to find some easy way to cut lists to the limited size.
returns me first 100 dwellers of the list.
(By the way, expression says: "ERR: list index out of bounds" if the list is not long enough. But same expression works ok with strings).
Then I have tried to create a function, that will push an item to the list and cut it to the size I need.
And... it won`t work. I have found some method in "Code Patterns": make a context and transfer variables like db:db.
But I`m pretty sure, there should be some other way to expain to the function, which variable I want to be pushed.
Code: Select all
(0 100 '("Some" "long" "list"))
(By the way, expression
Code: Select all
(-100 100 '("Some" "long" "list"))
Then I have tried to create a function, that will push an item to the list and cut it to the size I need.
Code: Select all
(define (push-cut what where how-long)
(push what where)
(if (> (length where) how-long)
(set 'where (0 how-long where)))
0)
But I`m pretty sure, there should be some other way to expain to the function, which variable I want to be pushed.