neitzel@infbs.UUCP (02/16/87)
The following puzzle was quite amusing for (prep?) us this afternoon: For a string containing quoting backslashes, compute the boolean vector that marks all those backslashes -- but not backslashes that are quoted on their part! i.e.: FUN 'a\*b\\c' yields: 0 1 0 0 1 0 0 FUN 'a\\\*' yields: 0 1 0 1 0 The usual puzzle contraint applies, of course: Don't use a loop in FUN. Send solutions to: Martin Neitzel ...seismo!mcvax!unido!infbs!neitzel
paull@hpcvck.UUCP (02/24/87)
What about FUN {is assigned} 1 {drop} {nand} {scan} 1 {catenate} '\' {equals} STRING The key is nand-scan, the 1s get everything started off on the right foot. Good puzzle.
paull@hpcvck.UUCP (02/24/87)
Oops, I forgot the negate FUN {is assigned} {negate} 1 {drop} {nand} {scan} ... ^^^^^^^^
graifer@net1.UUCP (03/02/87)
In article <4000002@hpcvck.HP> paull@hpcvck.HP (Paul Liebert) writes: >What about > >FUN {is assigned} 1 {drop} {nand} {scan} 1 {catenate} '\' {equals} STRING > ^ > {negate} > I tried this, and it didn't seem to work... I got two ones followed by a string of zeros almost all cases. A little reflection revealed the error. It is a result of a common confusion about the scan operator used with non-associative diadic primitives. if: R {is assigned} f\V then R[I] {is assigned} f/I{take}V for all I {element of} {iota}{rho}V and (this is the key) the COMPRESS EVALUATES RIGHT TO LEFT. Thus, {nand}\1 1 0 0 0 1 0 0 1 1 {comment} not 1 0 1 1 1 ! -- Dan Graifer graifer@net1.UCSD.EDU Disclaimer: Nobody ever listens to me anyways; Why should they start now?
ljdickey@water.UUCP (03/05/87)
In article <427@net1.UCSD.EDU>, graifer@net1.UCSD.EDU (Dan Graifer) writes: > In article <4000002@hpcvck.HP> paull@hpcvck.HP (Paul Liebert) writes: > Thus, > > {nand}\1 1 0 0 0 > 1 0 0 1 1 > {comment} not 1 0 1 1 1 > Dan Graifer > graifer@net1.UCSD.EDU > Disclaimer: Nobody ever listens to me anyways; Why should they start now? Dan is right. APL\11 has had a problem with scan for some time and it seems that nobody is fixing it. You could check this expression: -\ {iota} 5 The result should be 1 -1 2 -2 3. The APL\11 gives 1 1 2 2 3. It is just wrong. The essential test for correctness of scan is this: ( f \ V ) [N] <-----> f / N {take} V The APL\11 gets the right hand side right but not the left hand side. I think I know the solution, if anyone want to try to fix it. -- L. J. Dickey, Faculty of Mathematics, University of Waterloo. ljdickey@water.UUCP ljdickey%water@waterloo.CSNET ljdickey%water%waterloo.csnet@csnet-relay.ARPA ljdickey@water.BITNET UUCP: ...!watmath!water!ljdickey
paull@hpcvck.UUCP (03/11/87)
1000 pardons for making suggestions without first trying them out. My previous understanding (where I got this I don't know) was that RESULT[n] = RESULT[n-1] {operator} INPUT[n] This behaviour is consistent for the and, or, and plus operators which constituted the bulk of my experience. Thanks for setting me straight