Page 1 of 1

regular expressions

Posted: Wed Nov 12, 2008 4:36 pm
by stan_qaz
You know the famous quote about regular expressions?
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. — Jamie Zawinski

Re: regular expressions

Posted: Thu Nov 13, 2008 4:31 am
by Ikeb
:lol: Good one.

Actually even if the former is solved, the latter remains. These suckers are tough to maintain because they're not exactly self-documenting. They remind me of APL programming. ;)

Re: regular expressions

Posted: Thu Nov 13, 2008 5:40 am
by stan_qaz
I remember APL, beer usually makes it go away as I didn't have to actually use it, just read the code.

How Does APL Compare with other Languages?

APL is a very concise language. It is normal for APL programs to have one-fifth as many instructions as programs written in other languages, and one-tenth to one-twentieth the number of instruction lines. Among the reasons for this is that APL is a symbolic language, and single symbols often replace multiple lines of code. Here is a simple comparison of a numerical sort in BASIC, FORTRAN, and APL:

BASIC
----------------------------
10 DIM X(100), (100)
20 READ N
30 FOR I =1 TO N
40 READ X(I)
50 NEXT I
60 FOR I=1 TO N
70 LET A=X(I)
80 LET L=1
90 FOR J=1 TO 10
100 IF A<X(J) THEN 130
110 LET A=X(J)
120 LETL=J
130 NEXT J
140 LET Y(I)=A
150 LET X(L)=1000000.
160 PRINT Y(I)
170 NEXT I
180 DATA
...
...
...
XXX END


FORTRAN
--------------------------------
DIMENSION X(100),Y(100)
READ(5,10) N,(X(I),I=1,N)
10 FORMAT (15/(F10.2))
DO 20 I=1,N
A=X(I)
L=1
DO 15 J=1,N
IF(A-X(J))15,15,12
12 A=X(j)
L=J
15 CONTINUE
Y(I)=A
20 X(L)=100000.
WRITE(6,30) (Y(I),I=1,N)
30 FORMAT(E15.2)
END

APL
-----
Image

Or a fully functional game of Conway's Life in APL
Image

Re: regular expressions

Posted: Thu Nov 13, 2008 6:11 pm
by Ikeb
stan_qaz wrote: Or a fully functional game of Conway's Life in APL
Image
I remember that one! I think my version had three lines ... but couldn't figure out what I had done when I came back to it several weeks later. :? I actually programmed Life in several languages to get familiar with the coding methods.

Back to APL, while I was going to college, some of the computer sciences types had a contest to get the code down to one line for translating base 10 numbers into Roman Numerals. I chimed in with a version but was floored by someone's version that did it in a single line. :evil:

I recall that the computer center had several Selectric typewriters and I spent hours delving into APL nuances using up reams of trees. :roll: I now see that APL lives on so I'll have to check into this again ... now that fewer trees are needed. :D

Re: regular expressions

Posted: Thu Nov 13, 2008 7:41 pm
by Pierre
You guys are giving your ages away. I remember working on IBM 650 computers. On them the O/S had to be loaded for every job in the form of 80 column cards. :lol:

Re: regular expressions

Posted: Fri Nov 14, 2008 3:39 am
by Ikeb
Oh yeah!! The good old days when we were in intimate contact with our computers .... and GOTO instructions were the only way to get things done. ;)