| PLEX86 | ||
|
want shell should I learn 4
WHat "scalar" (or indeed "vector") are you talking about? Arrays are a concept in your mind. One interacts with their representatives in a computer lanuage by reading and writing (the representatives of) their elements. It's got all the bearing possible, since I am a mathematical logician, and a theoretical computer scientist who has a major part of his research in the area of programming language semantics. Sure it can .. I don't know what that means. If you mean "set the elements to 1 2 3 4, that's merely an aspect of your language. Nobody ever required that you have a single line that does that in every programming langauge with arrays in! What is better about it than want shell should I learn 5 On 2006-01-05, Peter T. Breuer That's a given. Does it need restating? As interactive bash has almost everything... for i in 1 2 3 4; do eval "myarray$i=$i" done ?? Of course, if you want me to package that up in a single command: seta() { array="$1" shift n=$# for i in `seq 1 $n`; do eval "${array}$i=$1" shift done } (hic - let's ignore a minor problem with spacing) and then you can call want shell should I learn 7 On 2006-01-05, Peter T. Breuer If you thinks that's all there is to usihng a shell at the... seta myarray 1 2 3 4
I don't need destruction. But if ya really wants, add a eval "${array}size=$n" to the above routine, and then implement destroy as follows: destroy() { array="$1" eval "n=${array}size" for i in `seq 1 $n`; do eval "${array}$i=" shift done } and then you can type destroy myarray I don't know what that does. But anyway, you really shoudl be getting the idea that languages implement your concepts via an algebra of operations - the arrays don't really "exist" in any real sense. Peter
|
||||
Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||