Just change all your

' '

to

''

(<' ') does not match (<'') .

Henry Rich

On 3/17/2017 9:33 PM, Linda A Alvord wrote:
After looking atg the rosetta code I tried the following:

  Is there a way to get from cr2 to cr ?

]ehs=: 5$a:
]cr=: (('English';'red') 0 3} ehs);<('Dane';'tea') 0 2}ehs
]cr=: cr, (('German';'Prince') 0 4}ehs);<('Swede';'dog') 0 1 }ehs
]A=: ;: 'English Dane German Swede'
┌───────┬────┬──────┬─────┐
│English│Dane│German│Swede│
└───────┴────┴──────┴─────┘
     ]B=:4 4$'';' ';'red';' ';' ';'tea';' ';'';'';' ';' ';'Prince';'dog';' ';' 
';' '
┌───┬───┬───┬──────┐
│   │   │red│      │
├───┼───┼───┼──────┤
│   │tea│   │      │
├───┼───┼───┼──────┤
│   │   │   │Prince│
├───┼───┼───┼──────┤
│dog│   │   │      │
└───┴───┴───┴──────┘
    cr2=:A,.B
    ]>cr-:cr2
0
    (>cr)-:cr2
0
    >cr
┌───────┬───┬───┬───┬──────┐
│English│   │   │red│      │
├───────┼───┼───┼───┼──────┤
│Dane   │   │tea│   │      │
├───────┼───┼───┼───┼──────┤
│German │   │   │   │Prince│
├───────┼───┼───┼───┼──────┤
│Swede  │dog│   │   │      │
└───────┴───┴───┴───┴──────┘
    cr2
┌───────┬───┬───┬───┬──────┐
│English│   │   │red│      │
├───────┼───┼───┼───┼──────┤
│Dane   │   │tea│   │      │
├───────┼───┼───┼───┼──────┤
│German │   │   │   │Prince│
├───────┼───┼───┼───┼──────┤
│Swede  │dog│   │   │      │
└───────┴───┴───┴───┴──────┘
    cr
┌────────────────┬─────────────┬──────────────────┬──────────────┐
│┌───────┬┬┬───┬┐│┌────┬┬───┬┬┐│┌──────┬┬┬┬──────┐│┌─────┬───┬┬┬┐│
││English│││red││││Dane││tea│││││German││││Prince│││Swede│dog│││││
│└───────┴┴┴───┴┘│└────┴┴───┴┴┘│└──────┴┴┴┴──────┘│└─────┴───┴┴┴┘│
└────────────────┴─────────────┴──────────────────┴──────────────┘
    <cr2
┌────────────────────────────┐
│┌───────┬───┬───┬───┬──────┐│
││English│   │   │red│      ││
│├───────┼───┼───┼───┼──────┤│
││Dane   │   │tea│   │      ││
│├───────┼───┼───┼───┼──────┤│
││German │   │   │   │Prince││
│├───────┼───┼───┼───┼──────┤│
││Swede  │dog│   │   │      ││
│└───────┴───┴───┴───┴──────┘│
└────────────────────────────┘

Linda

-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of 'Jon Hough' via Programming
Sent: Thursday, March 16, 2017 8:43 AM
To: Programming Forum
Subject: [Jprogramming] Who owns the zebra? with J

I stumbled across this Stackoverflow question[0], based on an old puzzle, and I 
really liked some of the answers. And of course, I started thinking how to do 
it in J.

Has anyone written a J solution to this problem?

[0] 
http://stackoverflow.com/questions/318888/solving-who-owns-the-zebra-programmatically/42184547#42184547

Regards,
Jon
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to