Looking for better names for array operations 
Author Message
 Looking for better names for array operations

I use often use COUNT for something other than what it's name implies.
For example:

: type  0 ?do  count emit  loop drop ;

In this case, COUNT should probably go by another name.
I've been thinking of UNLAY, since it deals with strings.  LAY and UNLAY
seem like pretty useful primitives.

Sample usage:

: unlay         ( a -- a+1 c )  count ;
: lay           ( a c -- a+1 )  over c! 1+ ;

: type          ( a n -- )
      0 ?do     unlay emit
        loop    drop ;

: cmove         ( asrc adest n -- )
      0 ?do     swap unlay
                swap lay
        loop    2drop ;

-LAY and -UNLAY could be similar except index backwards.  I don't
know what to call versions that would deal with cell-size data.

Any suggestions for names?

-- Brad



Sat, 16 Jan 1999 03:00:00 GMT  
 Looking for better names for array operations


Quote:

>I use often use COUNT for something other than what it's name implies.
>For example:

>: type  0 ?do  count emit  loop drop ;

>In this case, COUNT should probably go by another name.
>I've been thinking of UNLAY, since it deals with strings.  LAY and UNLAY
>seem like pretty useful primitives.

>Sample usage:

>: unlay         ( a -- a+1 c )  count ;
>: lay           ( a c -- a+1 )  over c! 1+ ;

>: type          ( a n -- )
>      0 ?do     unlay emit
>        loop    drop ;

>: cmove         ( asrc adest n -- )
>      0 ?do     swap unlay
>                swap lay
>        loop    2drop ;

>-LAY and -UNLAY could be similar except index backwards.  I don't
>know what to call versions that would deal with cell-size data.

>Any suggestions for names?

>-- Brad



We even have a string version called "s!++".

I have no idea where this notation came from :-)



: c!++ ( a c -- a+1 )    over c! 1+ ;


: --c! ( a c -- a-1 )    swap 1- tuck c! ;

: !++ ( a c -- a+1 )     over ! cell+ ;


: --! ( a c -- a-1 )      swap cell- tuck c! ;

: s!++ ( a1 a2 l2 -- a1+l2 )  
\ copy l2 bytes from a2 to a1 and leave a1+l2 on the stack


Regards

Pal Nyland

---
Pal Nyland
Linkcom Business Development AS
P.O. 197
N-6401 Molde

Phone: +47 71215744
Fax:   +47 71215717



Sun, 17 Jan 1999 03:00:00 GMT  
 Looking for better names for array operations

|> I use often use COUNT for something other than what it's name implies.
...
|> I don't
|> know what to call versions that would deal with cell-size data.

|> Any suggestions for names?


- anton
--
M. Anton Ertl                    Some things have to be seen to be believed

http://www.complang.tuwien.ac.at/anton/home.html



Tue, 19 Jan 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Collection>>flatten - looking for a better name

2. [array names -inorder name]

3. array name ARRAY regexp

4. how to access arrays with variable for array names and index

5. access to array if name of array is variable

6. HOWTO: reference elements of an array if array name is in a variable

7. avoid a blocking operation on a (named) pipe / timeout on a pipe

8. operations on open array (Incompatible assignement)

9. operations on open array (Incompatible assignement)

10. O() notation for Arrays operations and why is there no List class

11. Is this array operation correct?

12. macro for efficient array operations

 

 
Powered by phpBB® Forum Software