log10 &.(".@>)dj
+---------+---------+---------+---------+
|2.3791786|2.3802293|2.3768323|2.3761205|
+---------+---------+---------+---------+


R.E. Boss


-----Oorspronkelijk bericht-----
Van: [email protected]
[mailto:[email protected]] Namens Hahn, Harvey
Verzonden: maandag 29 december 2008 22:26
Aan: Programming forum
Onderwerp: [Jprogramming] How to use ": in boxed conversion?

I'm trying to create a copy of Yahoo's DJIA market data from 1928 to
present, but substituting logarithms in place of actual data (since
they're often easier to work with for ratios, percentage changes, etc.).

Here's a sample 4-element row (4 days) of boxed data:
   
   ]dj=. '239.43';'240.01';'238.14';'237.75'
+------+------+------+------+
|239.43|240.01|238.14|237.75|
+------+------+------+------+
   
   log10=: 10^.]    NB. convenience definition
   
   NB. <items is the "standard" way of boxing the items in a list:
   NB. ( J definition:  items=: "_1 )
   
   ]djlog=. <items log10(".>dj)
+-----------+-----------+-----------+-----------+
|2.379178566|2.380229337|2.376832349|2.376120526|
+-----------+-----------+-----------+-----------+

Everything's fine, except that the above are floating values rather than
literals, as in the original market data table.  So I attempted to use
": to do the conversion, placing it where I thought would be the correct
position:

   ]djlog=. <items (": log10(".>dj))
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|2|.|3|7|9|1|7|8|5|6|6| |2|.|3|8|0|2|2|9|3|3|7| | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

That didn't work, so...

   ]djlog=. <":items log10(".>dj)
+-----------+
|2.379178566|
|2.380229337|
|2.376832349|
|2.376120526|
+-----------+

That didn't work either.  Just for the heck of it, I tried...

   ]zzzz=. ": <items log10(".>dj)
+-----------+-----------+-----------+-----------+
|2.379178566|2.380229337|2.376832349|2.376120526|
+-----------+-----------+-----------+-----------+
   $zzzz
3 49       NB. !!!!

That DEFINITELY didn't work!  I've put the ": everywhere in the sentence
that I can think of, but none of the attempts worked correctly.  So how
can I do what I want??  Thanks in advance!

Harvey

----------------------------------------------------------------------
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