The snippet you display seem to indicate that you are on a nice nix
64 bit system. The lines you include are simply trying to read a file
into a variable/noun "t" and is failing because the file
'/home/vy/temp/WORDS.LST' doesn't exist... The list used in the jwiki
article is the one available as "WORD.LST" from the itasoftware site
that you cite. Perhaps you did download it and saved it, then simply
misspelled it in your attempt to read it in j (you have "WORDS.LST"
rather than "WORD.LST".... )
The count of t ( #t ) simply counted the number of bytes in the copy
of the file.
The next step in the wiki example puts each of the "lines" from the
word list into a box - and the count of boxes (# word) is 173528. If
you are asking how putting the list into boxes is accomplished ( word
=. <;,_2 t ) then I think you really should try reading more in the j
documentation about "Cut" ( ;. ) which can be found in the vocabulary
section of the documentation, e.g.
http://www.jsoftware.com/help/dictionary/vocabul.htm
Rather than deal with 173528 words, perhaps a 3 word example (excerpt
from illustrated problem) would suffice.
]words =. <;._2 'able deed deified writer '
+----+----+-------+------+
|able|deed|deified|writer|
+----+----+-------+------+
The desire is to find words which are palindromes. Again, a read in
the J documentation will show some nice tools for managing data.
Reverse ( |. ) is one of them. e.g.
|. 'spacer'
recaps
One could apply reverse to the boxed list -
|. words
+------+-------+----+----+
|writer|deified|deed|able|
+------+-------+----+----+
but in this case, what is wanted is the reversal of each of the words
(see entry for Dual ( &. ) in the vocabulary - i.e.
|. &.> words
+----+----+-------+------+
|elba|deed|deified|retirw|
+----+----+-------+------+
so if one makes a comparison of the words and their reversed form -
words = |. &.> words
0 1 1 0
We see that the first and last are not equal, while the middle two
are palindromes. The next step simply reduces the list to only the
ones of interest -
words #~ words = |. &.> words
+----+-------+
|deed|deified|
+----+-------+
I hope you can see the benefits of trying examples like this to learn
more about J and how algorithms are expressed in it.
At 12:45 +0300 2008/04/26, Volkan YAZICI wrote:
Hi,
I saw Roger HUI's solution[1] to Palindromic Pangram puzzle[2] and very
interested in the algorithm used behind. I'm a foreigner to J and
couldn't manage to evaluate steps described in the code snippets:
vy (~) [502:0]$ j64-602/bin/jconsole
read=: 1!:1
# t=: read <'/home/vy/temp/WORDS.LST'
|file name error: read
| #t=: read<'/home/vy/temp/WORDS.LST'
I don't want to behave disrespectful, but what I really wonder is the
algorithm/logic of the solution, instead of J itself. Excuse me if this
the wrong list to ask this questions, but would somebody mind
translating codes in the boxes located in solution page[1] to pseudo
codes?
Regards.
[1] http://www.jsoftware.com/jwiki/Puzzles/Palindromic_Pangram
[2] http://www.itasoftware.com/careers/puzzles07.html
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm