Tag Archives: APL

More APL funny-banana

Earlier this month the latest modifications to Dyalog APL had their annual outing. As usuall, those of us who had lots of experience with this dialect loved it. Those of us who had only a passing aquaintance with Dyalog, I am one, felt like learners without a teacher.

I remebered the flaw APL has, berzerk notation. Learning new APL features is like learning a new writing system. If you like learning new notation, APL is your thing. However, you have to motivate yourself to learn a new language principle, such as, how operators remove the need for iterators in APL. Like me, you wil have logged off after the first half-hour of an afternoon-long presentation.

What they presented was, I think, how hierachies remove the need for parsers, regexps, and filling systems. Honestly though, I will have to ask at the next meeting.

Tagged ,

A(funny-banana) Programming Language

If you like learning programming languages as much as I do then you will have heard of APL. If you heard about it when I did, your first encounter with it will have been in a libruary with a text book a note pad and a pen. These days, however, you need to find a web site that runs an online APL and prepare a kata or two to code on it.

In the 1980’s, my text book started me off gently with 2+3 and, eventually, got me to to conjecture what the ackerman hierachy was. I did not just learn how to programme in APL, but also what APL was for. In case you are wondering; APL is mathematical; APL is array oriented; APL is for people who like something difficult to study, that is not just a kata.

Incidentally, the meaning of “kata” in far eastern languges is not “exercise” or “puzzle” or “problem”; it is “curse”. The confusion arose from its use in martial arts. “Draw your sword!”, says the referee, the competitor does so, without hitting the referee. Then says the referee,”You are cursed! Your enemy is standing and you are sitting! Draw you sword again!”. The competitor sits on the floor, his sword is at a funny angle due to his clothes. He stands and attacks in one motion, without falling over. “Well done, you are a hero!”says the referee.

Now, back to programming.

Given most of the above; you will not want to start your adventures in APL by installing it on your own machine, or by just searching for “tryapl”. What you will need to do is have some kind of learning strategy first. It is this step that gives most people the impression of APL as a difficult, over complex, and somehow pointless language. This is because most people have a kill the monster attitude to learning, that if only they get past the kata they know everything in one big bang. This is not true, and its disproof is one of the reasons that I like APL so much. A reason I was in the libruary that hot summer in the 1980’s was that, my tutors at my FE college decided that they wanted me to keep learning programming after my ‘O’ levels ended. By various means, such as Socratic Dialogue and, reading my subject notes, they made sure that I had a learning programme. An important step, that most people skip nowadays. In less hysterical language, have clear goals in mind and a defined way of achieving them.

Now, grasshopper, what is 2+3 and what is 2÷3 ? If you study it in the right order, APL does not much more complicated than this. You can write a DBMS in less than 20 statements. ditto a caching data shaper. ditto lots of things that I never seem to have time to do!

Tagged ,

Import This, Import That, Import Shoes, Export hat

(approx 5 min read)

Recently, I found the twisty turny way to a new Computer Club. One of its main interests is programming, I hope that another is programme design. On my first session I found out just how twisty turny a D programme can be. It starts with, enough import statements to take the space of an entire programme in APL to do the same thing. It does not use just for, but foreach, map and split as iterators. They tell me at the BAA that APL does not need iterators.

However, there is a usefull function in the D programme, an enhancement of startsWith. It does not simply match the head of a string to a single character but, to any of a string of them. It uses uniform function call syntax, and a default matching string, to simplify the interface to functionality. I suppose that it is this kind of insight into one’s own code that computer clubs are about, and the twisty turny rubbish that I coded in the mean time is just a run up to the heights of origional code.

Tagged ,

The square root of minus one — possable objections

In my last post on the subject I skated over some possable objctions to GNU/APL’s calculation of the square root of minus one. On the one hand, the result could be that APL has crashed and “0J1” simply nonsense. On the other, it could be a special trapped case that leads ¯1*÷2 to automatically give this result without calculation.

These however, do not chime well with FSF’s reputation as a software publisher or the outright statement in the documentation that complex numbers are fully catered for.  On the other hand, I am still uable to install matrix division.  These two are unrelated, I hope!
It is left as an excercise for the reader to confirm these cases on their own systems, or to see me at a LUG some time this month.
Tagged , ,

Square root of minus one — the result

apl-snapshotIf you can see the expression and its evaluation on the snapshot of an APL session, you will see that GNU APL has not crashed and has delivered a result “0J1”. This is 0+1i in the  notation that APL uses for complex numbers– “J” instead of “i” and no addition sign. This proves that APL is aware of complex numbers.

Tagged , ,

APL and complex numbers, is it intelligent ?

When I met up with the concept of the square root of minus one for the first time I was a busey minded child, with a pile of old popular science books and even older text books to rummage through.

In one of them, I think it was called “mathematicians delight”, there was a bit about how you could have a number that when multiplied by itself gave ¯1, a major oddity then, to me.

I was used to numbers mis-behaving like this.  The author described how to do maths with this number he called and then said that you could do geometry with it.This did not worry me then. I was used to adult twitties like this.  Some years after this I learned about complex numbers, rather than just reading about them.

In a snide and more mathematically educated spirit I hope to have APL calcuate the square root of minus one by typing ¯1*÷2 into an unsuspecting laptop, to see if APL can detect the need for complex numbers.

Tagged , ,

How this APL prog, and most data processing, works

Initialise

∇ FN a ⍝ A  programme called FN with one parameter called “a”

N← ⍳ a⍝ the numbers from 1 to N in a vector

N← 1↓ N⍝ 1 is a special case, drop it before sieve starts
P←2⍝ 2 is the first prime, we assume, put it in P, the vector of primes
“starting with N is ” N ” and P is ” P
“entering loop”

process

topend:scan ← ((⌈(N÷N[1]))≠⌊(N÷N[1]))⍝ this is a sieveing test for prime numbers
N← scan/N⍝here we apply the test

if (we are at the end of processing) then go to the end

→(0=⍴N)/0⍝ if N is now fully sieved out of primes then go to the end of the programme

deliver interim output

P← P,N[1]⍝ this is really processing but if it is done before the 0=⍴N test then we exit with an error at the end of the processing loop

‘N is ‘ N
‘P is ‘ P

‘scan is ‘ scan

go back to process

→topend

the end

Tagged , , ,

what does this APL programme do ?

That APL programme I published recently finds the prime numbers from 1 to the  parameter value a.

How does it do it :-

To be continued……

Tagged , ,

APL esolang of “What does this do ?”

This entry contains apl characters and may not display correctly without an apl font

What does this, roughly ten line long, APL programme do ? And can you do it as concisely as this in any other language ?

∇ FN a

N← ⍳ a

N← 1↓ N
P←2
“starting with N is ” N ” and P is ” P
“entering loop”
topend:scan ← ((⌈(N÷N[1]))≠⌊(N÷N[1]))
N← scan/N
→(0=⍴N)/0
P← P,N[1]
‘N is ‘ N
‘P is ‘ P
‘scan is ‘ scan
→topend

The usual responses are “no idea” and  “No of course not ” respectively. To be contiuned…….

Tagged , , ,

APL esolang of esolangs part so many

Recently, I had some major difficulties with a prime number test. It relied on dividing by the first member of a list. Naturally I did not notice that the list started with one, leaving me at the next step with an empty list that was divied by zero. At this point my APL crashed with an obscure error. Not just the programme I was running  but my interpretor as well!

Tagged , ,