Hi everybody! Please how can I delete an elelment of a skill list?
Nour, The following document will bring you from darkness to ... Nour The Cadence SKILL Language User Guide which you can check out from your UNIX terminal at the following location : $CDSHOME/doc/sklanguser/sklanguser.pdf -> Chapter 8 : Advanced List Operations -> Section 9 : Removing Elements from a List -> Line ... I'm too lazy to count the lines ;-) Enjoy yourself ! PS : For those who are still wondering what : "from darkness to ... Nour" means. Nour in Arabic means light ;-)
Hi, you can use the "remove" option: for example - lst=list(1 2 3 4) lst2=remove(3 lst) now lst=(1 2 3 4) ; and lst2=(1 2 4) or you can use "remd": remd(3 lst) now lst=(1 2 4)
Just a few more comments note that this'll remove all elements equal to 3, so that lst=list(1 2 3 2 3) lst2=remove(3 lst) will result in lst2='(1 2 2) remd is destructive, i.e. it modifies the list itself (while remove works on a copy of the list). But there's a catch : lst=list(1 2 3 4) remd(1 lst) => (2 3 4) lst => (1 2 3 4) remd can not modify where lst is "pointing to", so it can't remove the car of a list. Therefore it's safer to use lst=remd(1 lst) also, be careful with destructive operations ; consider that symbols are "pointing" to lists, and therefore when two symbols are pointing to the same list, modifying one also affects the other : lst=list(1 2 3 4) lst2=lst ;; <= both are pointing to the same list here remd(2 lst) => (1 3 4) lst2 => (1 3 4) one last word : to destructively remove the element at index i in the list lst, rplacd(rplacd(nthcdr(i-1 lst) nthcdr(i+1 lst)) Cheers, Stéphane
S. Badel wrote, on 05/06/08 13:38: Also, you should consider whether a list is the right data structure if you're deleting stuff from it - especially if removing elements based on a position in the list as in Stéphane's example above. If it's unordered, perhaps a hash (an "association table" in SKILL terminology) makes more sense - as created by makeTable. You can also remove() elements from tables. Andrew.