----- Original Message -----
From: Harry Ohlsen <[EMAIL PROTECTED]>
To: Some Linux Users Group <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, December 15, 2000 8:27 AM
Subject: Re: [SLUG] Learning to program
> Which is why you really need to start with a language that allows you to
> play with as many different programming methods as possible. Of course,
> that's almost a vote for C++, so one needs to add "... and doesn't make
you
> spend more time tracking down silly mistakes that the language shouldn't
> let you make (or should recover from) than learning the concepts". Ie,
> make sure it's got garbage collection, for example, and preferably none of
> those darned pointers that can scribble anywhere!
Thats why you use PostScript! You can program [very inefficently] in a
`procedural' [its still functional actually, it just looks procedural]
manner, or [somewhat more efficently] in a functional manner.
However, it fails on the "make you spend more time tracking down silly
mistakes that the language shouldn't let you make" clause. [Mismanaged
stacks get ugly real fast].
And you can do real work in PostScript too! :) I've appended one of my
imfamous uni examples I wrote earlier this year [as a student]. The
original example program was written in several languages with the goal
being to find the minimum and maximum of a list of numbers. To say the
least, the lecturer was quite amused :) [The course? COMP1200 -
programming was beyond its scope, but the Lecturer wanted us to volunteer
examples of the 'standard problem' in other langauges for future groups
studying the course]
Several other examples were written in Perl, C, C++, Python, and even
Miranda.
[I also grant permission to reproduce this example as long as my original
accreditation remains intact :) - This was done for fun, and I whole
heartedly admit there would probably have been a more efficent way to have
written this in postscript - This is as it was originally published on the
ANU internal newsgroups.]
--
+-================================================-+
| Crossfire | This message was brought to you |
| [EMAIL PROTECTED] | on 100% recycled electrons |
+-================================================-+
----BEGIN EXAMPLE----
% Sample in postscript.
%
% Chris Collins <[EMAIL PROTECTED]>
%
% Reads from stdin, the number of elements, then the elements,
% and prints out (on stdout) the minimum and maximum value.
%
% Ghostscript only. Do not use this on the laser printers.
% Btw, don't expect to understand it either :)
5 dict begin
(%stdin) (r) file /sin exch def
(%stdout) (w) file /sout exch def
sin 20 string readline pop cvi dup 0 eq
{ sout (No Numbers\n) writestring quit } if
/count exch def
% first element.
sin 20 string readline pop cvi
dup /min exch def
/max exch def
count 1 sub /count exch store % decrement
{
count 0 eq { exit } if
count 1 sub /count exch store % decrement
sin 20 string readline pop cvi
dup min lt { dup /min exch store } if
dup max gt { dup /max exch store } if
pop
} loop
sout (Minimum = ) writestring
sout min 20 string cvs writestring
sout ( Maximum = ) writestring
sout max 20 string cvs writestring
sout (\n) writestring
end
quit
----END EXAMPLE----
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug