Looks better.

UN=:+./&.([:q:^:_1 p:)

IS=:*./&.([:q:^:_1 p:)

1 2 3 3 3 UN 3 3 3 3 3 4 5 6

3 3 3

1 2 3 3 3 IS 3 3 3 3 3 4 5 6

1 2 3 3 3 3 3 4 5 6

On Tue, Oct 30, 2018 at 7:56 AM Don Guinn <[email protected]> wrote:

> You're right. The trick is to make them prime numbers. But it's not pretty.
>
> IS=:(_1 p:[:q:+.&([:*/[:p:]))/
>
> UN=:(_1 p:[:q:*.&([:*/[:p:]))/
>
> 1 2 3 3 3 UN 3 3 3 3 3 4 5 6
>
> 1 2 3 3 3 3 3 4 5 6
>
> 1 2 3 3 3 IS 3 3 3 3 3 4 5 6
> 3 3 3
>
> On Tue, Oct 30, 2018 at 4:58 AM 'Bo Jacoby' via Programming <
> [email protected]> wrote:
>
>>
>> IS=.+.&.(*/)
>>
>> UN=.*.&.(*/)
>>
>>
>> This still works for multisets of prime numbers.
>>     Den tirsdag den 30. oktober 2018 11.55.04 CET skrev 'Bo Jacoby' via
>> Programming <[email protected]>:
>>
>>
>>    IS=.[:q:+.&(*/)
>>
>>  UN=.[:q:*.&(*/)
>>  2 3 3 5 IS 3 5 5 5
>> 3 5
>>  2 3 3 5 UN 3 5 5 5
>> 2 3 3 5 5 5
>> This works for multisets of PRIME numbers only.
>>
>>
>>     Den tirsdag den 30. oktober 2018 10.46.17 CET skrev R.E. Boss <
>> [email protected]>:
>>
>>  IMO we should interpret the intersection and the union of two
>> (multi)sets (sets X with X >:&# ~.X) in the same way as is done by the GCD
>> and the LCM of two numbers.
>> So for two numbers N and M with (multi)sets of primefactors A and B, we
>> should have (N +. M) = */(A IS B) and (N *. M) = */ (A UN B), with
>> IS=intersection and UN = union of the (multi)sets A and B.
>> Obviously we require (A IS B) =&(/:~) B IS A  and also (A UN B) =&(/:~) B
>> UN A for all (multi)sets A and B.
>> E.g.
>>     1 2 3 3 3 IS 3 3 3 3 3 4 5 6
>> 3 3 3
>>     1 2 3 3 3 UN 3 3 3 3 3 4 5 6
>> 1 2 3 3 3 3 3 4 5 6
>>
>> What are elegant and efficient J-definitions for IS and UN?
>>
>>
>> I have constructed
>>   UN_reb=: ([:(~.@{.#~ {. >.//.{:) |:@,&(({.,#)/.~))
>> and
>>   IS_reb=: ([:(~.@{.#~ {. <.//.{:)  ([|:@, ],~ 0,.~ -.~&:({."1),
>> -.&:({."1))&(({. , #)/.~))
>>
>>   1 2 3 3 3 UN_reb 3 3 3 3 3 4 5 6
>> 1 2 3 3 3 3 3 4 5 6
>>   1 2 3 3 3 IS_reb  3 3 3 3 3 4 5 6
>> 3 3 3
>>       1 2 3 3 3 UN_reb~ 3 3 3 3 3 4 5 6
>> 3 3 3 3 3 4 5 6 1 2
>>       1 2 3 3 3 IS_reb~ 3 3 3 3 3 4 5 6
>> 3 3 3
>>
>>   a=: 1e7?.@#1e6
>>   ts'a UN_reb a+499999'
>> 0.76631908 4.6996013e8
>>   #a UN_reb a+49999
>> 12186812
>>   ts'a IS_reb a+499999'
>> 0.76073743 3.3554592e8
>>   #a IS_reb a+49999
>> 7813188
>>
>>
>> R.E. Boss
>> ----------------------------------------------------------------------
>> 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