Trying to word the question which originally came to mind when I looked at this problem (converting the "list notation" of a c.f.) to a decimal value:

How would one go about throwing in the additional "1"s into the spaces (gaps) of the paling fence..? (There is one less "1" compared to the number of integers in the "list notation" [if I always write out the integer part, even if it is "0").

If the two lists I like to "interweave" don't agree in number of items, I obviously get a lenght error.

   ] v=. i.4
0 1 2 3
   ] w=. 3 $ 1
1 1 1
   ,v ,. w
|length error
|   ,v    ,.w

Would there be a (similar, slightly modified) way to do this, or does one need a (very) different approach..?

-M

At 2016-03-11 10:18, you wrote:
To keep students organized in dealing with fractions I sometimes (on a good day) have them work out intermediate results of continued fractions like phi = [1; 1, 1, 1, ...] or sqrt(2) = [1; 2, 2, 2, ...]. This example I found at http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/cfINTRO.html 45/16 = [2; 1, 4, 3] I then went on clumsily, further down using the "strategy" (as Linda Alford put it): ln=. 2 1 4 3 NB. list notation (shorthand) ] ip=. {. ln NB. get integer part 2 ] fp=. }. ln NB. get fractional part 1 4 3 ] nn=. (# fp) $ 1 NB. produce additional numerators (all 1) 1 1 1 ] fpn=. ,nn ,.fp NB. "interweave" fractional part with added numerators to yield 1 1 1 4 1 3 ] lne=. ip ,fpn NB. "list notation (expanded)" value for the Cont. Fraction function 2 1 1 1 4 1 3 cf=. +`% / cf lne 2.8125 ^.^ 45r16 2.8125 -M At 2016-03-11 08:54, you wrote: >Maybe... The new list interweaves the two original lists. The >"strategy" also applies to lists of numbers. Linda -----Original >Message----- From: Programming >[mailto:[email protected]] On Behalf Of Henry >Rich Sent: Thursday, March 10, 2016 6:58 PM To: >[email protected] Subject: Re: [Jprogramming] Interweave >You're right... Now, how would you describe the order? Would 'index >order" be enough? The Dictionary says "normal order" and then goes >on to define it. I have looked for years for the right words. It >has to be short and intuitive - not a mathematical definition. How >about "in the order in which they appear in y"? Henry Rich On >3/10/2016 6:30 PM, Nicholas Spies wrote: > This is perhaps a >quibble, but... > > Looking at the NuVoc definition of , y Ravel > > >The following statement and the example directly below it... > >-------- > Produces a list ><http://code.jsoftware.com/wiki/Vocabulary/AET#List> > containing >all the atoms > <http://code.jsoftware.com/wiki/Vocabulary/AET#Atom> >in y, in order. > > An atom ><http://code.jsoftware.com/wiki/Vocabulary/AET#Atom> is > converted >to a 1-atom list > ><http://code.jsoftware.com/wiki/Vocabulary/AET#List>, a list > ><http://code.jsoftware.com/wiki/Vocabulary/AET#List> is left > >unchanged, and any noun > ><http://code.jsoftware.com/wiki/Vocabulary/AET#Noun> > of higher >rank <http://code.jsoftware.com/wiki/Vocabulary/AET#Rank> is > >flattened into a list > ><http://code.jsoftware.com/wiki/Vocabulary/AET#List> > > ]z=: 0 >10 20 +/ i. NB. sample noun > 0 1 2 3 4 > 10 11 12 13 14 > >20 21 22 23 24 > > ,z > 0 1 2 3 4 10 11 12 13 14 20 21 22 23 >24 > ------------------- > > ...and >also... > > ,'ace',.'bdf' > > abcdef > > > ...give the first >impression that Ravel puts the items into lexical > order, > > which >is misleading, as shown by the example 2 under Common Uses: > > > ]a >=: 4 4 ?@$ 100 > > 89 91 1 24 > > 88 43 43 32 > > 85 84 27 31 > > 10 >11 49 90 > > +/ 50 < , a > > 6 > > ,a > > 89 91 1 24 88 43 43 32 85 >84 27 31 10 11 49 90 > > > Since NuVoc is targeting new users, the >'in order' statement should. > IMHO, specify explicitly the order as >being <whatever description is appropriate>. > > > >Nick > > > > > > > > On Thu, Mar 10, 2016 at 5:48 PM, Roger Hui ><[email protected]> > wrote: > >> ,'ace',.'bdf' >> >abcdef >> 'ace',@,.'bdf' >> abcdef >> >> >> On Thu, Mar 10, 2016 >at 2:47 PM, Roger Hui >> <[email protected]> >> >wrote: >> >>> ,|:'ace',:'bdf' >>> abcdef >>> 'ace'([: , >|:@,:)'bdf' >>> abcdef >>> >>> >>> On Thu, Mar 10, 2016 at 2:42 PM, >Kip Murray <[email protected]> >>> wrote: >>> >>>> A quickie -- >how do you interweave two equal-length lists, so >that >>>> >>>> 'ace' itw 'bdf' >>>> abcdef >>>> >>>> --Kip >Murray >>>> >>>> >>>> >>>> -- >>>> Sent from Gmail Mobile >>>> >-------------------------------------------------------- ----------- > > >>> --- 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 >--------------------------- ------------------------------------------- >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

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

Reply via email to