>>
APLDN Home

>>
Events

>>
Trainings

>>
APL Books

>>
APLDN Links

>>
Discussion Groups

>>
Downloads

>>
Articles

>>
Library

>>
Learning Tools

>>
APLDN User IO

>>
APL2000.com




Features

Author Thread: Two ideas from A+
Michael.Hughes
Two ideas from A+
Posted: Thursday, July 22, 2004 11:26 AM (EST)

1.  They have variables called slot fillers (Just 2 element nested) First is a list of names, second is an enclosed list of corresponding data items.

Very handy and easy to do in APL+Win.  However they have implemented a left arg to pick which if a name in the strand from the disclose of the first element, returns the corresponding element of the second.

 

(ie)  data{gets}('aa' 'bbb' 'cc' 'dddd')(('aaaaaaa') (1 2 3)('aaaa')(3 4{rho}{iota} 12))  

 

'aa'{pick}data returns

'aaaaaa'  etc.

 

They use symbols but this works with nested text.  Its a very useful data structure and alot of time is wasted with a fn call to

 ((1{pick} data){iota}(left arg)) {pick} 2{pick} data 

 

The char left arg is much neater and more efficient.

 

2.  Contexts, or namespaces.  Most other languages have them and it would help manage code in a large ws.  Even the basic of sub dividing the ws would be better than nothing.  i have even tried spitting up the code for a form into a COM but because we can't have the GUI in the main workspace with it interacting with the COM like you can set Excel to you end up spending alot of time communicating event/properties between the APL workspace and the COM object.  Contexts would be much neater.


Comments:

Author Thread:
davin.church
Two ideas from A+
Posted: Thursday, July 22, 2004 12:26 PM (EST)

I (and probably many others) use a similar structure quite frequently, but it's a vector of nested name/value pairs (e.g.  ('a' 4) ('b' 17) ('c' 'who')).  I also have an alternate form where it's a two-column matrix.

 

I like the idea of pick taking a character left argument, but it probably doesn't fit into the theoretical language design very well.  But until then, we can use a trivial function to pick out those values for us (though updating them is less clean).

     

Michael.Hughes
Two ideas from A+
Posted: Thursday, July 22, 2004 3:59 PM (EST)

Well, the way the char left arg of pick would work is to use selective assignment

 

(ie)    ('aaa'{pick}data) {gets} newvalues

 

I also use a trivial function but I think this is much neater (and more efficient) to use {pick}.  Once easy and effiicient to use its amazing how useful the structure is. 

The advantage of using the two element data structure is that the 1st pick gives you the list of fields so its easy to get a list of valid field names.

In the case proposed to check whether a data item exists is

(enclose name) {member} 1 {pick} data

to append is simply

data {gets}data {catenate} {each} {enclose}{each}( name newdata)

or data {gets} data {catenate}{each} (newdata of same structure)

merge is a little more interesting but can be achieved using 1 {pick}

  

     



APL2000 Official Web Site

Make others happy and joyful. Your happiness will multiply a thousand fold.
--- Swami Sivananda

APLDN Home   |    |  Events   |  Trainings   |  APL Books   |  APLDN Links   |    |  Discussion Groups   |    |  Downloads   |  Articles   |  Library   |  Learning Tools   |  APLDN User IO   |  APL2000.com   |