Whoops, thanks!
~greg
krsnadas.org
--
On 27 September 2016 at 18:55, Joey K Tuttle wrote:
> Try
>
>1!:0 <'ny.xhtml'
--
For information about J forums see http://www.jsoftware.com/forums.htm
Try
1!:0 <'ny.xhtml'
> On 2016Sep 27, at 18:44, greg heil wrote:
>
> i have a file on WX 64b
> 1!:0'ny.xhtml'
> +-+
> ¦ny.xhtml¦2016 9 26 21 7 42¦1882324¦rw-¦-a¦
> +-+
> but cannot open it...
>
i have a file on WX 64b
1!:0'ny.xhtml'
+-+
¦ny.xhtml¦2016 9 26 21 7 42¦1882324¦rw-¦-a¦
+-+
but cannot open it...
1!:21 'ny.xhtml'
|domain error
| 1!:21'ny.xhtml'
also fails on the other (2) te
On a problem like this, like most problems in real life, execution speed
is less important than
* ease of coding
* ease of documentation
* confidence in the solution
* scalability
Henry Rich
On 9/27/2016 9:06 PM, 'Jon Hough' via Programming wrote:
That is a great solution. Thanks.
Just for f
That is a great solution. Thanks.
Just for fun I compared it with Mike Day's:
NB. just an arbitrary long string
text=.'THISISJUSTSOMERANDOMSENTENCEFORTESTINGTHEZIGZAGPROBLEMSOLUTIONSTHISISJUSTSOMERANDOMSENTENCEFORTESTINGTHEZIGZAGPROBLEMSOLUTIONSTHISISJUSTSOMERANDOMSENTENCEFORTESTINGTHEZIGZAG
Yes, thanks. I didn't think this problem could be solved purely tacitly, but
seems I was wrong.
By the way, small nitpick, but your solution fails for the case of number of
rows = 1:
1 tconvert 'SOMETEXT'
On Wed, 9/28/16, 'Mike Day' via Programming
How about brute force?
zigzag=:[:,./[:((5 4$' ')(0 0;2 0;4 0;2 2)}~])"1[:]_4,\]
zigzag 'PAYPALISHIRING'
P A H N
A P L S I I G
Y I R
On Tue, Sep 27, 2016 at 1:27 PM, Henry Rich wrote:
>zzc =: (#@] $ ((] , -) i.)@<:@[) ;@:(3 zzc 'PAYPALISHIRING'
> PAHNAPLSIIGYIR
>
> Henr
zzc =: (#@] $ ((] , -) i.)@<:@[) ;@:(
You might enjoy this tacit version:
start =: i.@(<. #)
nstep =: (0 >. (-~ #)) >.@% <:@[
diffs =: (,:~ |.)@:+:@start
tconvert =: (]{~(#@])([-.~~.@:<.) ,@|:@(+/\)@ (start, nstep $diffs))
M
On 27/09/2016 15:27, 'Mike Day' via Programming wrote:
You might enjoy this tacit version:
start =: i.@(<. #)
nstep =: (0 >. (-~ #)) >.@% <:@[
diffs =: (,:~ |.)@:+:@start
tconvert =: (]{~(#@])([-.~~.@:<.) ,@|:@(+/\)@ (start, nstep $diffs))
M
On 27/09/2016 15:27, 'Mike Day' via Programming wrote:
Thanks. It's nice to find an array-bas
Thanks. It's nice to find an array-based solution to something that
looks loopy!
These comments might help. (I talk about rows and columns as in the
original problem,
though in my code the intermediate array is transposed. Even columns are
diagonals
in the original!):
"difs" is the expected
> NB. colon separates monad and dyad sections
I did not know that, thanks.
Your solution is great. I'll have to spend a little time figuring out what's
going on, but I can't find any flaws yet. And much more J-like than mine.
Regards,
Jon
On Tue, 9/2
Yes, our messages crossed.
I'm lazy with verb definitions, nearly always using 3 : 0 even
for a dyad. I could have written
cv =: 3 : 0
3 cv y NB. monad section: supply a default larg for monad use
:NB. colon separates monad and dyad sections
[dyad section]
)
then 3 would be the
Not simply this?
+/2 3 4 2
11
Cheers,
Erling
On 2016-09-27 09:35, Skip Cave wrote:
NB. I am attempting to learn recursion using ^:
NB. A simple recursion:
2+^:(3) 2
8
NB. This is equivalent to
2+2+2+2
8
NB. What if I want to change the left argument on each recursion?
NB.
Sorry, I gave the correct verb in my second mail.
Thanks for your solution. I'm not really sure I understand what cv is...
Is it a monad (i.e. 3 : 0)? It has a reference to the x argument, so it seems
to be a dyad.
Also, what is the purpose of the colon on the first line of cv?
Thanks,
Jon
-
rmo's definition?
Anyway, here's an approach which works on the indices.
Please note that I haven't tested it thoroughly for boundary problems.
I just consider the rising diagonals as extra columns. Top & bottom
indices will be reduplicated, but can be removed with nub.
eg for LHA = 5, we get
Small bug in my verb. This is the correct code:
convert =: 4 : 0
rows =. x
text =. y
len =. # y
if. 0 = len do. ''
elseif. 1 = len do. text
elseif. 1 = rows do. text
elseif. 1 do.
k=. 0
l=. 0
res =. ''
NB. loop through the rows
while. (k < rows) *. k < len do.
res =. res, k{text
NB. how much to in
This is a programming challenge from here:
https://leetcode.com/problems/zigzag-conversion/
The challenge is to convert a string into a "zig zag" formation with the given
number of rows.
e.g. (from the link)
PAYPALISHIRING is transformed into PAHNAPLSIIGYIR (the link explains clearly
this trans
gethttp addon updated to include curl.exe with SSL support and
a ca cert file. Tested with getting
https://curl.haxx.se/index.html
use at your own risk. ;-)
Вт, 27 сен 2016, Gilles Kirouac написал(а):
> Bill
>
> On https://curl.haxx.se/download.html ,
> under Win32 - generic, the third line i
Though, I should add, induction and recursion are very similar.
There's a significant difference, though. Induction is much more like
what recursive people call "tail recursion". In other words, once a
function is done executing and you go on to the next function
evaluation, you never come back to
^: is induction, not recursion. You should use either $: or a named
routine if you want recursion.
Also, ^: is defined such that the left argument is constant and the
right argument is the result of the previous function evaluation. (Or,
initially, the initial right argument.)
Still, you can sort
NB. I am attempting to learn recursion using ^:
NB. A simple recursion:
2+^:(3) 2
8
NB. This is equivalent to
2+2+2+2
8
NB. What if I want to change the left argument on each recursion?
NB. Instead of 2 each time, I want to add 2, then 3, then 4.
NB. I know there are much easier wa
21 matches
Mail list logo