Or if the data is unordered.

   8 100 (]#~[:~:/>:/) 2 45 10 300

45 10

On Sun, Sep 24, 2017 at 7:07 PM, Louis de Forcrand <ol...@bluewin.ch> wrote:

> You could compress twice:
>
> drng=: {.@[ (<: # ]) {:@[ (>: # ]) ]
>
> Perhaps faster on large data?
> You could reorder and filter out the data under the lower bound first if
> your data is usually smaller than it to speed up the verb.
>
> Louis
>
> > On 24 Sep 2017, at 22:37, Joey K Tuttle <j...@qued.com> wrote:
> >
> > Yes, my bad. I did sort and forgot that I had. I should have caught that
> silliness - sorry for the noise.
> >
> > This was a problem that I worked on in APL back in 1971 when I had a
> tape with many thousands of data points and wanted to put them in buckets
> (actually just count them) - it was that struggle that inspired putting /.
> into j.
> >
> > The problem was made a little harder by only having 64kbytes of
> workspace....  Ah, how times have changed!
> >
> > - joey
> >
> >> On 2017Sep 24, at 13:22, Skip Cave <s...@caveconsulting.com> wrote:
> >>
> >> I suspect that Joey sorted a before breaking it into ranges:
> >>
> >>   ]b =. /:~ a
> >>
> >> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> >>
> >>
> >>   /:~ ( 5 10 15 I. b) </. b
> >>
> >> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>
> >> │1 2 3 4 5│6 7 8 9 10│11 12 13 14 15│16 17 18 19 20│
> >>
> >> └─────────┴──────────┴──────────────┴──────────────┘
> >>
> >>
> >> In that case you don't need the final sort:
> >>
> >>
> >>   ( 5 10 15 I. b) </. b
> >>
> >> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>
> >> │1 2 3 4 5│6 7 8 9 10│11 12 13 14 15│16 17 18 19 20│
> >>
> >> └─────────┴──────────┴──────────────┴──────────────┘
> >>
> >>
> >> Skip Cave
> >> Cave Consulting LLC
> >>
> >>> On Sun, Sep 24, 2017 at 3:15 PM, Skip Cave <s...@caveconsulting.com>
> wrote:
> >>>
> >>> Joey T. said:
> >>>
> >>>   /:~ (0 5 10 15 I. a) </. a
> >>> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>> │1 2 3 4 5│6 7 8 9 10│11 12 13 14 15│16 17 18 19 20│
> >>> └─────────┴──────────┴──────────────┴──────────────┘
> >>>
> >>> However when I try the same thing:
> >>>
> >>>     /:~ (0 5 10 15 I. a) </. a
> >>>
> >>> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>>
> >>> │2 5 3 1 4│9 7 8 10 6│12 14 11 13 15│20 19 16 18 17│
> >>>
> >>> └─────────┴──────────┴──────────────┴──────────────┘
> >>>
> >>> j805/j64/windows
> >>>
> >>> Library 8.05.14
> >>>
> >>>
> >>> So on Joey's system the box contents and the boxes are sorted. On my
> >>> system just the boxes are sorted. ???
> >>>
> >>>
> >>> Skip
> >>>
> >>> Skip Cave
> >>> Cave Consulting LLC
> >>>
> >>>> On Sun, Sep 24, 2017 at 3:03 PM, Joey K Tuttle <j...@qued.com> wrote:
> >>>>
> >>>>   /:~ (0 5 10 15 I. a) </. a
> >>>> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>>> │1 2 3 4 5│6 7 8 9 10│11 12 13 14 15│16 17 18 19 20│
> >>>> └─────────┴──────────┴──────────────┴──────────────┘
> >>>>
> >>>> But that is a more boring (and perhaps less useful) result...
> >>>>
> >>>>
> >>>>> On 2017Sep 24, at 12:57, Skip Cave <s...@caveconsulting.com> wrote:
> >>>>>
> >>>>> Jimmy G said:
> >>>>>
> >>>>> With key /. and <
> >>>>>
> >>>>> (0 5 10 15 I. a) </.     a
> >>>>>
> >>>>> <<<>>>
> >>>>>
> >>>>>   a
> >>>>>
> >>>>> 9 12 2 20 14 11 13 15 7 5 3 19 8 1 4 16 10 6 18 17
> >>>>>
> >>>>>
> >>>>>   (0 5 10 15 I. a) </.     a
> >>>>>
> >>>>> ┌──────────┬──────────────┬─────────┬──────────────┐
> >>>>>
> >>>>> │9 7 8 10 6│12 14 11 13 15│2 5 3 1 4│20 19 16 18 17│
> >>>>>
> >>>>> └──────────┴──────────────┴─────────┴──────────────┘
> >>>>>
> >>>>>
> >>>>> So Jimmy's solution does box the ranges, but the ranges are not in
> the
> >>>>> range order specified by the left argument. Why? And how can you
> create
> >>>> a
> >>>>> verb that will keep the ranges in     ascending     order?
> >>>>>
> >>>>>
> >>>>>
> >>>>> Skip Cave
> >>>>> Cave Consulting LLC
> >>>>>
> >>>>> On Sun, Sep 24, 2017 at 2:37 PM, Jimmy Gauvin <
> jimmy.gau...@gmail.com>
> >>>>> wrote:
> >>>>>
> >>>>>> With key /. and <
> >>>>>>
> >>>>>> (0 5 10 15 I. a) </.     a
> >>>>>>
> >>>>>> you can also count them
> >>>>>>
> >>>>>> (0 5 10 15 I. a) #/. a
> >>>>>>
> >>>>>>
> >>>>>> On Sun, Sep 24, 2017 at 3:19 PM, Skip Cave <s...@caveconsulting.com
> >
> >>>>>> wrote:
> >>>>>>
> >>>>>>> So that brings up another interesting problem. How
> >>>>>>> to
> >>>>>>>   box ranges
> >>>>>>> ​?​
> >>>>>>> :
> >>>>>>>
> >>>>>>>     ]a=:>:?~20
> >>>>>>> 9 12 2 20 14 11 13 15 7 5 3 19 8 1 4 16 10 6 18 17
> >>>>>>>
> >>>>>>>     0 5 10 15 brng a
> >>>>>>> ┌─────────┬──────────┬──────────────┬──────────────┐
> >>>>>>> │2 5 3 1 4│9 7 8 10 6│12 14 11 13 15│20 19 16 18 17│
> >>>>>>> └─────────┴──────────┴──────────────┴──────────────┘
> >>>>>>>
> >>>>>>> S
> >>>>>>> ​o how do you construct brng?​
> >>>>>>>
> >>>>>>> Skip Cave
> >>>>>>> Cave Consulting LLC
> >>>>>>>
> >>>>>>> On Sun, Sep 24, 2017 at 2:09 PM, 'Mike Day' via Programming <
> >>>>>>> programm...@jsoftware.com> wrote:
> >>>>>>>
> >>>>>>>> I was about to send something when we had to go out for a bit...
> >>>>>>>>
> >>>>>>>> My best so far is
> >>>>>>>>     ((] #~ 1 = I.)~ (0 _1 + ])) ~
> >>>>>>>> assuming I've copied it correctly...
> >>>>>>>>
> >>>>>>>> Mike
> >>>>>>>>
> >>>>>>>> Please reply to mike_liz....@tiscali.co.uk.
> >>>>>>>> Sent from my iPad
> >>>>>>>>
> >>>>>>>>> On 24 Sep 2017, at 18:45, Skip Cave <s...@caveconsulting.com>
> >>>> wrote:
> >>>>>>>>>
> >>>>>>>>> Marshall,
> >>>>>>>>>
> >>>>>>>>> Wow! that is neat! I hadn't really understood dyadic I. but this
> >>>>>> forced
> >>>>>>>> me
> >>>>>>>>> to         try to understand it:
> >>>>>>>>>
> >>>>>>>>>     8 100 (]#~1=I.) 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 10 45
> >>>>>>>>>
> >>>>>>>>>     8 100 I. 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 0 1 1 2
> >>>>>>>>>
> >>>>>>>>>     1 = 8 100 I. 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 0 1 1 0
> >>>>>>>>>
> >>>>>>>>>     (1 = 8 100 I. 2 10 45 300) # 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 10 45
> >>>>>>>>>
> >>>>>>>>>     8 100 I. 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 0 1 1 2
> >>>>>>>>>
> >>>>>>>>>     1 8 100 I. 2 10 45 300
> >>>>>>>>>
> >>>>>>>>> 1 2 2 3
> >>>>>>>>>
> >>>>>>>>>     1 8 100 I. 2 10 45 300 450
> >>>>>>>>>
> >>>>>>>>> 1 2 2 3 3
> >>>>>>>>>
> >>>>>>>>>     1 8 100 350 I. 2 10 45 300 450
> >>>>>>>>>
> >>>>>>>>> 1 2 2 3 4
> >>>>>>>>>
> >>>>>>>>>     1 8 100 350 I. 300 2 45 10 450
> >>>>>>>>>
> >>>>>>>>> 3 1 2 2 4
> >>>>>>>>>
> >>>>>>>>> So now I'm getting a feel for I. Reading the terse Vocabulary
> >>>>>>> description
> >>>>>>>>> of dyadic I. didn't help much in making the I. functionality
> clear,
> >>>>>> at
> >>>>>>>>> least for me. The NuVoc description wasn't much more helpful, but
> >>>> the
> >>>>>>>>> examples after the description in Nuvoc cleared things up
> >>>>>> considerably.
> >>>>>>>>>
> >>>>>>>>> Also, the dissect tool was very helpful in figuring out how J
> parsed
> >>>>>>> the
> >>>>>>>>> whole dyadic verb. Who is the author of the dissect tool? That's
> a
> >>>>>>> great
> >>>>>>>>> help in learning J.
> >>>>>>>>>
> >>>>>>>>> Skip
> >>>>>>>>>
> >>>>>>>>> Skip Cave
> >>>>>>>>> Cave Consulting LLC
> >>>>>>>>>
> >>>>>>>>> On Sun, Sep 24, 2017 at 3:14 AM, Marshall Lochbaum <
> >>>>>>> mwlochb...@gmail.com
> >>>>>>>>>
> >>>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> Try
> >>>>>>>>>>
> >>>>>>>>>> rng =: ] #~ 1=I.
> >>>>>>>>>>
> >>>>>>>>>> it's about half as fast because I. is not very well-optimized.
> >>>>>>>>>>
> >>>>>>>>>> Marshall
> >>>>>>>>>>
> >>>>>>>>>>> On Sun, Sep 24, 2017 at 02:29:31AM -0500, Skip Cave wrote:
> >>>>>>>>>>> Here's a function I came up with to select numbers in a vector
> >>>>>> which
> >>>>>>>> are
> >>>>>>>>>>> within some range.
> >>>>>>>>>>>
> >>>>>>>>>>> Find all the numbers between 10 & 100 in a set of random
> numbers
> >>>>>>> from 0
> >>>>>>>>>> to
> >>>>>>>>>>> 200:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>         rng =. 4 : '((({.x)</y)*.(({:x)>/y))#y'
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>       10 100 rng ?50$200
> >>>>>>>>>>>
> >>>>>>>>>>> 89 91 32 85 84 27 31 20 28 66 96 93 22 85 39 97 82 35 90 67 34
> 35
> >>>>>> 67
> >>>>>>> 95
> >>>>>>>>>> 50
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> Between 120 & 180:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>         120 180 rng ?50$200
> >>>>>>>>>>>
> >>>>>>>>>>> 148 163 133 165 150 178 121 146 161 179
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> Is there a more concise/efficient way to select numbers in a
> >>>> range?
> >>>>>>>>>>>
> >>>>>>>>>>> Skip Cave
> >>>>>>>>>>> Cave Consulting LLC
> >>>>>>>>>>> ------------------------------------------------------------
> >>>>>>> ----------
> >>>>>>>>>>> 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/forum
> >>>> s.htm
> >>>>>>>>
> >>>>>>> ------------------------------------------------------------
> >>>> ----------
> >>>>>>> For information about J forums see http://www.jsoftware.com/forum
> >>>> s.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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to