Okay, let's try this approach (although I did like what Kip and Mike put
together).
fun=: (' '-.~":)@(({. (* , (* +/)) }.) - 0 0 , 1&{)
fun 7 2 5
143547
fun 9 9 9
8181153
fun 9 0 9
08181
Cheers, bob
On Dec 14, 2014, at 8:37 AM, Skip Cave <[email protected]> wrote:
> Answer:
>
> the verb fun takes three integers as input.
>
> the output has three sections.
>
> 1. The first section is the product of the first two integers.
>
> 2. The second section is the product of the first and third integers.
>
> 3. the third section is the sum of those first two products, minus the
> second integer.
>
> The final output is a vector of the three results, with the spaces removed.
>
> This should hold true for any three integers.
>
> rb =:]#~(' '~:]) NB. Remove all blanks
>
> 'a b c' =. 2 4 6
>
> fun =. 3 : 'rb ": (a*b), (a*c), ((a*b)+(a*c)-b)'
>
> fun
> 81216
>
> 'a b c' =. 9 9 9
> fun
> 8181153
>
> 'a b c' =. 6 12 14
> fun
> 7284144
>
> ​Skip
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm