Mental models of problem solving

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Mental models of problem solving

Postby neeraj on Fri May 31, 2013 5:50 am

Code: Select all
 X←'AEDEE'
   Y←'BEEE'
   X⍳Y
6 2 2 2
   ((⍴X)⍴⍋⍋X⍳X,Y)⍳(⍴Y)⍴⍋⍋X⍳Y,X
6 2 4 5


Above is an example of an idiom for progressive index without replacement. My question is that is it sufficient to know that such an idiom exists and use it if the need arises, or should the journeyman APL programmer also understand how they work? How did the original APLers create these idioms? Could they just see them in their mind's eye or was it a deliberate attempt to find a solution?
neeraj
 
Posts: 82
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Re: Mental models of problem solving

Postby Morten|Dyalog on Fri May 31, 2013 10:14 pm

I think the answer depends on whether the "journeyman" intends to one day become a master. In my opinion, studying the idioms *is* useful, as it will provide insights into array-oriented algorithms in general - and make it possible to construct solutions when you are faced with a problem which does not exactly fit any of the idioms that you know by heart.

My guess is that the answer to the question about the origins is that they came about through a combination of recreational activities and attempts to find solutions to real problems. Some of the complex ones came about as a result of studying and understanding simpler idioms, and realizing that they could be extended. Many of the early (and current) APLers have very strong backgrounds in mathematics and algorithms, giving them good platforms from which to construct even complex idioms "from scratch".
User avatar
Morten|Dyalog
 
Posts: 453
Joined: Tue Sep 09, 2008 3:52 pm

Re: Mental models of problem solving

Postby Roger|Dyalog on Wed Jun 05, 2013 8:57 pm

In Dyalog v14.0, x⍳y will be extended to look for major cells of x, subarrays of rank ¯1+⍴⍴x along the leading dimension of x. (For matrix arguments x⍳y will basically be the matiota idiom, x{(↓⍺)⍳↓⍵}y.) As well, there will be a new function, ≢x ←→ ⍬⍴(⍴x),1. There, in v14.0 the progressive index-of idiom can be extended readily to work on higher-ranked arrays:

      pi←{((≢⍺)⍴⍋⍋⍺⍳⍺⍪⍵)⍳(≢⍵)⍴⍋⍋⍺⍳⍵⍪⍺}

⎕rl←7*5
x←(3 6⍴'NeerajMortenRoger ')[?20⍴3;]
y←(4 6⍴'NeerajMortenRoger Dyalog')[?17⍴4;]

x pi y
1 6 2 7 8 9 20 3 10 12 11 13 0 20 4 19 14

(⍪⍳≢x) x y (⍪ x pi y)
0 Roger Morten 1
1 Morten Morten 6
2 Neeraj Neeraj 2
3 Neeraj Morten 7
4 Roger Morten 8
5 Roger Morten 9
6 Morten Dyalog 20
7 Morten Neeraj 3
8 Morten Neeraj 10
9 Morten Morten 12
10 Neeraj Neeraj 11
11 Neeraj Morten 13
12 Morten Roger 0
13 Morten Dyalog 20
14 Morten Roger 4
15 Morten Neeraj 19
16 Roger Morten 14
17 Morten
18 Morten
19 Neeraj
Roger|Dyalog
 
Posts: 238
Joined: Thu Jul 28, 2011 10:53 am

Re: Mental models of problem solving

Postby Phil Last on Thu Jun 06, 2013 7:57 am

I fully agree with Morten's second sentence but without the qualification of the first. If anyone is in a position to have to select such an algorithm he must be already well enough acquainted with the language to be able to understand the range and structure of its arguments and result and to use it in context.

The Phrasebook wiki http://aplwiki.com/PhraseBook was started to facilitate the acquisition of such skills. So far it hasn't attracted many contributors and until a lot more appear it will remain a potential rather than an actual resource.

Both the teaching and the understanding of an algorithm can be a difficult process. Anyone with a new or favourite algorithm or just one of which he feels a real understanding is asked to contribute a page of explanation to the wiki. Just copy an existing one and change it to suit. Or send an email to me or another past contributor and it will be added on your behalf.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest