Henry, Your explanation of how the conjunctions are parsed helped make the tree
diagrams make more sense. I gave up my idea.
f=: 13 :'(%@(%:@(-@(+@*:y'
5!:4 <'f'
┌─ %
── @ ─┤ ┌─ %:
└─ @ ─┤ ┌─ -
└─ @ ─┤ ┌─
Here's a 35 character J implementation:
a.{~(a.j}~a.{~|.j=.65 97+/~i.26)&i.
Example use:
a.{~(a.j}~a.{~|.j=.65 97+/~i.26)&i. '019abcABC|xyzXYZ+='
019zyxZYX|cbaCBA+=
And, as it happens, it can also be used as a stand alone verb definition:
F=: a.{~(a.j}~a.{~|.j=.65 97+/~i.26)&i.
F '01
Alpha_j_]`([{~26(([*<.@%~)+<:@[-|)i.)@.(e.~"1 0)'AbcazZ~! Hello,
World!'
ZyxzaA~! Svool, Dliow!
- Original Message -
From: Moon S
To: programming
Sent: Friday, January 22, 2016 8:33 PM
Subject: [Jprogramming] Blonde Code Golf - January Challenge - Alphabet Swap
Here's anoth
S=: (a.,~,|.t) {~ (a.,~,t=.a.{~97 65+/~i.26)&i.
S 'Hello, World!'
Svool, Dliow!
S 'A man, a plan, a canal, Panama!'
Z nzm, z kozm, z xzmzo, Kzmznz!
On Fri, Jan 22, 2016 at 5:33 PM, Moon S wrote:
> Here's another code golf challenge I found:
>
> http://www.blonde.net/blog/2016/01/18/
Here's another code golf challenge I found:
http://www.blonde.net/blog/2016/01/18/blonde-code-golf-january-16
In a string, swap a-z with z-a, A-Z with Z-A. Assume that you will always
get a valid string and that spaces and special characters should remain
unchanged.
alphaSwap('abcxyz') // -> zyx
If you click inside the sentence (at the top of the dissect display),
dissect will scroll the screen so that the result of the clicked word is
brought to a fixed point in the display, about midway left-to-right and
three-quarters of the way down the screen.
Useful if the display overflows the
Henry, I think I get it now.
Thanks very much for that long detailed explanation of parsing vs
execution. It helped a lot.
Also, the examples you gave earlier of dissecting #@> 'a';1 2 and #@:>
'a';1 2 really helped. (Eventually I changed 1 2 to 20 30 so that the 1 and
2 did not get confused with t
Unfortunately I have to add another bit of complication, after which you
will know everything.
What does it mean to "execute a@b"?
There are actually two things going on: the execution of the CONJUNCTION
@ and the execution of the VERB (a@b).
@ is a conjunction. It takes two operands, which
Hmm...
In addition to dissect (which focuses on the details of execution),
consider what trace (which focuses on the details of parsing) tells us
about one of your examples:
require'trace'
trace_jtrace_ ' #@>@:;:''a man a plan a canal'''
--- 4 Conj ---
#
@
>
#@>
--
The original message was correct, not this one.
I am very sorry for the confusion.
Henry and Raul,
Thanks for your replies to the message.
I am still trying to sort out the examples with the MIDDLE TINE and am
optimistic with dissect and the detail Henry gave. However, it sounds like
magic or do
# @ > @ ;:
is parsed as
(# @ >) @ ;:
This is not obvious. It's buried in the details of the parsing table.
The practical rule is that in a long sequence of modifiers, each
conjunction operates between its single right operand and everything to
its left, as if it were all parenthesized.
T
(Actually, no - it has to do with execution order and, of course, rank
- parsing is the first step of execution in J, but I didn't think that
one through properly.)
Thanks,
--
Raul
On Fri, Jan 22, 2016 at 11:03 AM, Raul Miller wrote:
> Order is important.
>
> Do you see why?
>
> (Hint: it has
Order is important.
Do you see why?
(Hint: it has to do with implicit parenthesis provided by parsing.)
Thanks,
--
Raul
On Fri, Jan 22, 2016 at 10:55 AM, Brian Schott wrote:
> [Sorry, that was a mistake. This is a resend]
>
>#@:>@:;:'a man a plan a canal' NB. 1
> 6
>#@:>@;:'a ma
[Sorry, that was a mistake. This is a resend]
#@:>@:;:'a man a plan a canal' NB. 1
6
#@:>@;:'a man a plan a canal' NB. 2
6
#@>@;:'a man a plan a canal' NB. 3
1 3 1 4 1 5
#@>@:;:'a man a plan a canal' NB. 4
1 3 1 4 1 5
#@(>@:;:)'a man a plan a canal' NB. 5
6
#@
#@:>@:;:'a man a plan a canal' NB. 1
6
#@:>@;:'a man a plan a canal' NB. 2
6
#@>@;:'a man a plan a canal' NB. 3
1 3 1 4 1 5
#@>@:;:'a man a plan a canal' NB. 4
1 3 1 4 1 5
#@(>@:;:)'a man a plan a canal' NB. 5
6
#@(>@;:)'a man a plan a canal' NB. 6
6
These
I think I finally understand the difference!
A=:'a man a plan a canal'
;:A
┌─┬───┬─┬┬─┬─┐
│a│man│a│plan│a│canal│
└─┴───┴─┴┴─┴─┘
f=: 13 :'#>;:y'
g=: 13 :'#@>;:y'
h=: 13 :'#@:>;:y'
f A
6
g A
1 3 1 4 1 5
h A
6
f
[: # [: > ;:
g
[: #@> ;:
h
[: #@:> ;:
16 matches
Mail list logo