Skip, I was asked this just the other day by my son in Primary Math, it is a 
beautiful solution for this (common) math question.

“How many different 3 digit house numbers can you produce if the hardware shop 
has no other supplies than unlimited quantities of 3’s, 4’s and 5’s and what 
are those numbers”

A math/statistics person says “1st number any of 3 4 5, 2nd number any of 3 4 
5, 3rd number any of 3 4 5” so there are 3 x 3 x 3 (or 27) house numbers.

But to produce the list, the beauty of “catalogue” (as its name implies) is a 
very elegant solution to these types of problems.

   { 3 4 5;3 4 5;3 4 5
┌─────┬─────┬─────┐
│3 3 3│3 3 4│3 3 5│
├─────┼─────┼─────┤
│3 4 3│3 4 4│3 4 5│
├─────┼─────┼─────┤
│3 5 3│3 5 4│3 5 5│
└─────┴─────┴─────┘

┌─────┬─────┬─────┐
│4 3 3│4 3 4│4 3 5│
├─────┼─────┼─────┤
│4 4 3│4 4 4│4 4 5│
├─────┼─────┼─────┤
│4 5 3│4 5 4│4 5 5│
└─────┴─────┴─────┘

┌─────┬─────┬─────┐
│5 3 3│5 3 4│5 3 5│
├─────┼─────┼─────┤
│5 4 3│5 4 4│5 4 5│
├─────┼─────┼─────┤
│5 5 3│5 5 4│5 5 5│
└─────┴─────┴─────┘

   $,{ 3 4 5;3 4 5;3 4 5
27

> On 20 May 2020, at 4:08 pm, Skip Cave <s...@caveconsulting.com> wrote:
> 
> Harvey,
> 
> ...
> If not, you get a very different result:
> 
> 1 2 3;4 5 6;7 8 9
> 
> ┌─────┬─────┬─────┐
> 
> │1 2 3│4 5 6│7 8 9│
> 
> └─────┴─────┴─────┘
> 
> {1 2 3;4 5 6;7 8 9
> 
> ┌─────┬─────┬─────┐
> 
> │1 4 7│1 4 8│1 4 9│
> 
> ├─────┼─────┼─────┤
> 
> │1 5 7│1 5 8│1 5 9│
> 
> ├─────┼─────┼─────┤
> 
> │1 6 7│1 6 8│1 6 9│
> 
> └─────┴─────┴─────┘
> 
> 
> ┌─────┬─────┬─────┐
> 
> │2 4 7│2 4 8│2 4 9│
> 
> ├─────┼─────┼─────┤
> 
> │2 5 7│2 5 8│2 5 9│
> 
> ├─────┼─────┼─────┤
> 
> │2 6 7│2 6 8│2 6 9│
> 
> └─────┴─────┴─────┘
> 
> ┌─────┬─────┬─────┐
> 
> │3 4 7│3 4 8│3 4 9│
> 
> ├─────┼─────┼─────┤
> 
> │3 5 7│3 5 8│3 5 9│
> 
> ├─────┼─────┼─────┤
> 
> │3 6 7│3 6 8│3 6 9│
> 
> └─────┴─────┴─────┘
> 
> 
> Skip Cave
> Consulting LLC
> 
> 
> On Mon, May 18, 2020 at 3:38 AM HH PackRat <hhpack...@gmail.com> wrote:
> 
>> On 5/17/20, HH PackRat <hhpack...@gmail.com> wrote:
>>> I need to convert the following list of 5 (in reality, far more)
>>> 11-character dates: ...
>>> to a list of 5 boxed dates: ...
>> 
>> Many THANK YOU's to those who responded!  As usual with J, there's
>> often more than one way to accomplish something--in this case, 5
>> completely different ways that I can choose to add to my personal J
>> vocabulary.
>> 
>> The shortest was Skip Cave's response, but, Skip, I have a question
>> about how/why yours works.  When I read the Vocabulary and NuVoc to
>> see how and why this works, I could not figure out how I would even
>> think to use "{" (catalogue) based on the information in those two
>> sources.  The NuVoc definition/description is "Combines ITEMS from the
>> ATOMS inside a BOXED LIST to form a catalogue."  My original list was
>> NOT boxed, so that description would automatically dismiss my example
>> from using "{".  Can you please clarify why "{" can be used to box an
>> unboxed list?
>> 
>> And, by the way, in my programming, I like to do things small step by
>> small step so that I can be sure everything works correctly at each
>> point.  My original goal in this case was to get the unboxed list
>> first boxed in the correct manner and then transpose it from a column
>> to a row.  (It's part of stock market data from a particular vendor
>> which is out of "standard" order and format.)  Three of the five
>> responses did both aspects (box and transpose) in a single
>> command--for which I am quite grateful.  It showed me again how
>> amazing J is!
>> 
>> 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

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

Reply via email to