Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!mach1!torn!utnut!cs.utexas.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.edu!umn.edu!csus.edu!sfsuvax1.sfsu.edu!emclean
From: emclean@sfsuvax1.sfsu.edu (Emmett McLean)
Subject: Re: APL one-liner needed for new novel
Message-ID: <1993Mar14.215651.14417@csus.edu>
Keywords: fantasy
Sender: news@csus.edu
Organization: San Francisco State University
References: <1993Mar12.113416.16509@telesoft.com>
Date: Sun, 14 Mar 1993 21:56:51 GMT
Lines: 204


In article <1993Mar12.113416.16509@telesoft.com> kst@telesoft.com (Keith Thompson @pulsar) writes:
>I'm posting this request on behalf of Rick Cook, a science fiction and
>fantasy author.  You can send any responses directly to him at
>rcook@bix.com.  I'll forward anything mailed to me or posted to this
>newsgroup (I *think* we should be receiving it here).

  I got him, but email him anyway this it's more recent.
>
>A little background: Rick Cook is the author of a series of novels
>about a C programmer who finds himself transported into a fantasy
>world, and proceeds to devise a programming language, operating system,
>and support tools to cast magical spells.  To create or edit a spell,
>for example, one summons a demon called an Emac.

>
>>         OK APLers, the deal is this. I'm working on the next Wiz
>> book (the fourth) and I need a line of APL code. What I am
>> looking for is the most georgeously complicated, totally bizarre
>> no-op I can find. It can be any dialect or version (although I'd
>> like to know what the dialect or version is so I can work it into
>> the story) but it should be mind-bendingly cryptic.
>>         If you want to call it an obfuscated APL competition,
>> fine, but it's got to fit on one line -- about 80 characters
>> or less  -- and it's got to _appear_ complicated to people
>> who think APL is a mis-spelled fruit.

How about d where

d=.(''"_)@(((([$:<:@]),(2&^@<:@]+<:@[$:<:@]))`(#.@(]#1:))`0: @.(#.@(0&=@[,(=]))))@]) :: (``"_)

   2 d 4

   d 4

 Explanation. If:
 b =.(([$:<:@]),(2&^@<:@]+<:@[$:<:@]))`(#.@(]#1:))`0: @.(#.@(0&=@[,(=])))
 Then (x b y) is the decimal representation of all combinations
 of n chose b bits. So,

   2 b 4
3 5 6 9 10 12

   #. b
0 0 1 1 
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0


"d" is just b rigged up so it always returns null. If it is
used monadically or dyadically.

As a demon, Emac should like b because it's multiply recursive.
Note that in reality d (or b) casts a nasty spell and eats up
resources. Don't try this.

50000 d 100000000000

  
>>         The winner gets mentioned in the dedication to the
>> book, "The Wizardry Consulted", which will come out next year
>> from Baen Books.

   Ummm.

This might fit into the plot and make the J functions you use more
meaningful.

========= topic=========
Invisible passwords in J
========================
If I assign the variable p :

   p =. ('name2';'112233'); < (<'name3'),(<!.('Emac';'111111') '001122')

Then no one can tell "name3" is associated with (say) Emac by only
listing p.

   p
+--------------+--------------+
|+-----+------+|+-----+------+|
||name2|112233|||name3|001122||
|+-----+------+|+-----+------+|
+--------------+--------------+

And if the password function (pwd) is defined as shown below, only
visible passwords are returned.

   pwd =. }."1@>@((>&({."1)@>@[ (i. ({:@$@[ {.!.' ' ])) ]) { [)

   p pwd 'name3'
+------+
|001122|
+------+
   p pwd 'name2'
+------+
|112233|
+------+


   But if pwd is redefined to :

   rpwd =. (pwd)`(}.@(>!._)@pwd) @. ((''&$)@((32&=)@(3!:0)@(>!._)@pwd))

   or (in indigenous J it is assigned as :)

   rpwd=.}."1@>@((>&({."1)@>@[ (i.({:@$@[{.!.' ']))]){[)`(}.@(>!._)@(}."1@>@((>&({."1)@>@[(i.({:@$@[{.!.' ']))]){[)))@.(''&$@(32&=@(3!:0)@(>!._)@(}."1@>@((>&({."1)@>@[(i.({:@$@[{.!.' ']))]){[))))

   The visible password for all users is returned except for "name3"
   in which case the invisible password is returned.

   p rpwd 'name3'
+------+
|111111|
+------+

   p rpwd 'name2'
+------+
|112233|
+------+

So (in the book) an unwitting user may work on an application where he is
using code influenced by the demon with a password file p.  In the course
of working on his own application (using this the demon associated software)
one of the values in the password file is changed and provided a hidden
name. Also, the pwd command is inadvertantly changed to rpwd.
Thus Emac gets access to all of the machines the unwitting user works on.

============topic=================
providing hidden clusters of verbs
==================================

In J the dyadic verbs (functions) for divide, matrix inv, and root
are "%" , "%." , and "%:" .  These verbs can be strung together with an `.

So the expression :

   t =. < %`%.`%:

+---------+
|+-+--+--+|
||%|%.|%:||
|+-+--+--+|
+---------+

   Is the box of three verbs.

   But "t" given below, is the box of three verbs with a 
   hidden set of boxed alternative verbs. In this case the zero
   verb, "d" as described above, and two zero verbs.

   t =. <!.(< 0:`d`0:) (%`%.`%:)

   So this t looks like the old t:

   t
+---------+
|+-+--+--+|
||%|%.|%:||
|+-+--+--+|
+---------+

  But you can see the hidden verbs by executing this.

   >!._ t
+-------------------+
|+--+-----------+--+|
||0:|+-+-------+|0:||
||  ||~|+-----+||  ||
||  || ||+-+-+|||  ||
||  || |||0|d||||  ||
||  || ||+-+-+|||  ||
||  || |+-----+||  ||
||  |+-+-------+|  ||
|+--+-----------+--+|
+-------------------+
   
So something could be written up to check for the Emac password:
11111,  and return the one set of verbs (either visible or invisible)
for all users but providing Emac the complement and access to both .


Finally if you wish to boggle non-APL'ers with cyrptic stuff you 
can throw this at them. It's far longer than the 80 character
min but it is outrageously cryptic.

h =.(''"_)@((((]; >./@((+/%#)"1@((=/~@(i.@])-(%.@%@>:@(+/~)@i. +/ .* (%\ i.&.<:@+:))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((((# ,:@(i.@-))!(#"1 ,.@(+ i.)))@] * ((,~ $ (# i.@-)) ! (,~ $ (+ i.)))@] * *:@((,~ $ (# i.)) ! (+/~@i.))@] * >:@(+/~)@i.@] * _1&^@(+/~@i.)@]) +/ .* (%\ i.&.<:@+:))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((%\ i.&.<:@+:) +/ .* (%.@%@>:@(+/~)@i.))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((%\ i.&.<:@+:) +/ .* (((# ,:@(i.@-))!(#"1 ,.@(+ i.)))@] * ((,~ $ (# i.@-))!(,~ $ (+ i.)))@] * *:@((,~ $ (# i.)








)!(+/~@i.))@] * >:@(+/~)@i.@] * _1&^@(+/~@i.)@]))@])@])))"0 ) :: (''"_) : ((]; >./@((+/%#)"1@((=/~@(i.@])-(%.@%@>:@(+/~)@i. +/ .* (%\ i.&.<:@+:))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((((# ,:@(i.@-))!(#"1 ,.@(+ i.)))@] * ((,~ $ (# i.@-)) ! (,~ $ (+ i.)))@] * *:@((,~ $ (# i.)) ! (+/~@i.))@] * >:@(+/~)@i.@] * _1&^@(+/~@i.)@]) +/ .* (%\ i.&.<:@+:))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((%\ i.&.<:@+:) +/ .* (%.@%@>:@(+/~)@i.))@])@])) , >./@((+/%#)"1@((=/~@(i.@])-((%\ i.&.<:@+:) +/ .* (((# ,:@(i.@-))!(#"1 ,.@(+ i








.)))@] * ((,~ $ (# i.@-))!(,~ $ (+ i.)))@] * *:@((,~ $ (# i.))!(+/~@i.))@] * >:@(+/~)@i.@] * _1&^@(+/~@i.)@]))@])@])))"0 )@] :: (''"_))@])


  Have fun, (I did)

  Emmett

