Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Linda Alvord
Numbers, too! Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of David Ward Lambert Sent: Monday, December 10, 2012 9:32 AM To: programming Subject: Re: [Jprogramming] Just for fun, verb cross cross

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread bob therriault
That is lovely Arie, It is that kind of elegance that I was chasing with my rougher attempts. Using the (+.|.) hook simplifies (|.+.]) precisely and the { 0 1 combined with ' ',. means that the selection of the string becomes a choice in each row of displaying either the corresponding

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Roger Hui
The expression fails if the argument has duplicate items. e.g. ((+.|.)@={0 1 ' ',.)'aabbb' |length error | ((+.|.)@={0 1' ',.)'aabbb' On Mon, Dec 10, 2012 at 10:18 AM, bob therriault bobtherria...@mac.comwrote: That is lovely Arie, It is that kind of elegance that I was chasing

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
Here's a version that works with duplicated values (except note that there was no specification for what the behavior should be in this case): (,@(#~01) (+.|.)@=)'abcde' a e b d c b d a e (,@(#~01) (+.|.)@=)'abcdedcba' a e a b d d b c c b d d b a e a -- Raul On

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Aai
Thanks for destroying my day. Here's a much longer alternative ' ' (,{~[:((+.|.)@= ({0 1) 0,.) 1+i.@#@]) 'baabb' b b a a a b b b b _ (,{~ [: ((+.|.)@=({0 1) 0,.) 1+i.@#@]) 1 2 1 2 1 _ _ 1 _ 2 2 _ _ 1 1 _ 2 _ _ 2 On 10-12-12 19:21, Roger Hui wrote: The expression fails if the

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread bob therriault
Thanks Roger, I guess this is why we race Ferrari's and go shopping in minivans. :) My first draft survives repeats, but I still find Arie's version beautiful (and functional within the specs of not having repeated items). t0=:((.|.1)@(*=)@::@i.@#){ ' ',] t0 'abcde' a a b b c d

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Stefano Lanzavecchia
Ugly as hell (but my J doesn't get any better without practicing): cross =.(((1 {. 0 # ]), ]) {~ (:*(|.+.])@(=/~))@i.@#) NB. Works for strings with replicated entries cross 'aabbcdeabcde' aa b b cc d d ee aa b b cc

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
And, for what it's worth, here's a different plausible implementation of cross (different only for the case of duplicated letters in the argument when compared with the version I posted, below): (,@(#~01) (+.|.)@=@(#\)) 'abcdedcba' Note that replacing = with =@(#\) should also work for Aai's

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread km
My solution works by preparing a left argument for From { . It has rank two solutions and is limited to string arguments. cross ([: (+. |.1) [: (= * :) [: i. #) { ' ' , ] cross 'a' a a a a a a a a a Kip Murray Sent from my iPad On Dec 10, 2012, at 1:48 PM, Raul

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread David Ward Lambert
Without looking studying the sentence evaluator, I expected +.|.@ (+. |.)@ to be identical to +.(|.@) |.@+. Date: Mon, 10 Dec 2012 15:41:52 -0500 From: Raul Miller rauldmil...@gmail.com To: programm...@jsoftware.com Subject: Re: [Jprogramming] Just for fun, verb cross Message-ID

Re: [Jprogramming] Just for fun, verb cross

2012-12-10 Thread Raul Miller
To: programm...@jsoftware.com Subject: Re: [Jprogramming] Just for fun, verb cross Message-ID: CAD2jOU8iKSKDjgPuPf26_wqUSd3QOgscqLcXkCtMC0xZj2o +o...@mail.gmail.com Content-Type: text/plain; charset=UTF-8 For what it's worth, here's a parenthesis free implementation of my two

Re: [Jprogramming] Just for fun, verb cross

2012-12-09 Thread bob therriault
First draft looks like this. (((.|.1)@(*=)@::@i.@#){ ' ',])'abcde' a a b b c d d e e (((.|.1)@(*=)@::@i.@#){ ' ',])'ab' aa bb One of the things that I like about J is the way it lets you build and test your ideas as you go. I look forward to more elegant solutions. Cheers, bob

Re: [Jprogramming] Just for fun, verb cross

2012-12-09 Thread Linda Alvord
Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Marshall Lochbaum Sent: Sunday, December 09, 2012 11:07 PM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Just for fun, verb cross Here's a pretty good version

Re: [Jprogramming] Just for fun, verb cross

2012-12-09 Thread bob therriault
Second draft is a little cleaner since rank 1 reverse is not required as the matrix is still boolean at this point. t=: (:@i.@# * (|.+.])@:=){' ',] t 'ab' aa bb t 'abcde' a a b b c d d e e Cheers, bob On 2012-12-09, at 8:01 PM, bob therriault wrote: First draft looks like