|
|||||
|
Reference Manual Terms Of Use About A+ Getting A+ A+ Community A+ Web Site |
Programs Written in A+99 Bottles of Beer was submitted to Tim Robinson's collection in 1997 by Malcolm Austin. It appears there in A+'s ASCII form. Here it uses the A+ font. Here's a variant of uniq(1) that does not require sorted input. However, trailing blanks are ignored on input and likely added on output and most grievously, standard input is ignored. APL programmers surely won't like the iteration. Bummed? Rewrite it and send it back.
#! /usr/local/bin/a+ -q
unique{x}:((xÉx)=É#x)/x
nl{x}:,"\n",@1 x
ã found these functions in /u/apter
btom{x}:>(Ó/>#¡x)Ù¡x
vtoe{y;x}:if (`null=©x) x else 1Õ¡(ÚxÅy)Úxû((~(1Ùx)Åy)/1Ùy),x
vtom{y;x}:btom{vtoe{y;x}}
noLines{x}:vtom{"\n";(-"\n"=¢1Ùx)Õx}
aû0Ò''
(nû¢1+#_argv) do {
a[,]ûnl sys.readmat >_argv[n+1];
}
if (0¨Òa) {
unique noLines a
}
sys.exit 0
Here's the same code in ascii mode which A+ parses as well:
#! /usr/local/bin/a+ -q
$mode ascii
unique{x}:((x iota x)= iota #x)/x
nl{x}:,"\n",@1 x
'found these functions in /u/apter';
btom{x}:>( max/># each x) take each x
vtoe{y;x}:if (`null= ? x) x else 1 drop each ( bag x in y) bag x := (( iota (1 take x) in y)/1 take y),x
vtom{y;x}:btom{vtoe{y;x}}
noLines{x}:vtom{"\n";(-"\n"=(-1) take x) drop x}
a := 0 rho ''
(n := (-1)+#_argv) do {
a[,] := nl sys.readmat >_argv[n+1];
}
if (0 ~= rho a) {
unique noLines a
}
sys.exit 0
I haven't installed the A+ fonts yet but I want to see the code with the A+ character set so I'll click here. |
||||
|
Thanks to the designers of www.xemacs.org for their inspirational look and feel. |
This page is part of the A+ website
<http://www.aplusdev.org/>
Maintained by webmaster@aplusdev.org Hosted by
This page last modified Fri Apr 4 10:55:18 EST 2003 © 1992-2008 Morgan Stanley Dean Witter & Co. All rights reserved. |
||||