Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!uwm.edu!caen!uunet!westport-news-srvr.westport.trirex.com!root
From: trirex!taff@uunet.uu.net (Tom Affinito)
Subject: J Suite vs cond
Message-ID: <1992Nov30.203655.1043@Trirex.COM>
Keywords: J, control, loop
Sender: root@Trirex.COM (Operator)
Reply-To: trirex!taff@uunet.uu.net
Organization: Trirex Systems Inc.
Distribution: na
Date: Mon, 30 Nov 1992 20:36:55 GMT
Lines: 47

Hi all,

Today's thought problem...how to do efficient, readable, cond/switch/case  
structures in J.

A paradigmatic function in Scheme might be the following, which returns  
true if the input is a list of atoms, and returns false otherwise:

(define lat?
  (lambda (a)
    (cond
      ((null? a)	#t)
      ((atom? (car a))	(lat? (cdr a)))
      (else		#f))))

In J, I (naively) only know how to express this as an explicit definition  
which uses labels for readability and suite reassignment.  Not only does  
this not look nice, I have to reinvent the label/suite assignment every  
time I have one of these functions, plus the code is relatively  
inefficient since I am not enjoying the tacit semi-compilation feature.

[Boolean vector production/selection solutions need not apply.  That's  
obvious.  I have a LOT of data and want to step through it].

What I'm interested in is your answer to these questions:

1) Is there another general way of cond-less programming that is easy to  
do in J?

2) I believe that the suite is a neat feature in J, but it does not help  
the programmer by capturing patterns of reuse that are typically needed.   
Forks and trains simplify code by capturing patterns of function  
application (good!), but there is no mechanism for recapturing common  
patterns of suite assignment such as while/for/cond (bad!), thus leading  
to increased use of explicit definition and individual stylistic solutions  
that are not commonly shared by a community of language readers.

Does J need a cond conjunction (or whatever) of some sort to  
simplify/clarify branching behaviour?

Suite is a great goto, but I don't have goto in Scheme (except call/cc  
which is more powerful anyway), and I don't use goto's in C.  Is suite an  
historical idea which should be dropped?

Desperately trying to do word-at-a-time processing,
Tom	:-)
taff@trirex.com
