> o o│o│o│
>>> ─┐ │ │ │
>>> o│o│o│o│
>>>
>>>
>>> The sum of first n odd numbers is simply n^2.
>>>
>>> How about some J code to generate figure 2.1 ?
>>>
>>>
>>>
>>>
>>>
>
ode to generate figure 2.1 ?
>>
>>
>>
>>
>>
>> On Tue, May 15, 2018 at 5:22 AM, 'Jon Hough' via Programming <
>> programm...@jsoftware.com> wrote:
>>
>>> Try this:
>>>
>>> smodd1=:+/@:>:@:+:@:i.
&g
Yes, it fits the bill with a minor adjustement:
n=:4
(o^:(n-1)) _1 1 }.":<'o'
───┐
o o o o│
─┐ │
o o o│o│
───┐ │ │
o o│o│o│
─┐ │ │ │
o│o│o│o│
On Tue, May 15, 2018 at 10:21 AM, Raul Miller wrote:
> Are you looking for something like this for "figure 2.1"?
>
>o=: _1 1 }. ":
acit verb was creating forks, as can be seen with dissect:
>> load 'debug/dissect'
>>dissect '+/1+2*i. 5'
>>
>>
>> But since the sum of the first N odd numbers is N^2
>> it is easiest to write
>> smodd=: *:
>>
>>
>>
----------------
> On Tue, 5/15/18, Skip Cave wrote:
>
> Subject: [Jprogramming] Summing odd numbers
> To: "programm...@jsoftware.com"
> Date: Tuesday, May 15, 2018, 5:29 PM
>
> A simple Quora question wants to know the
> formula to su
---
On Tue, 5/15/18, Skip Cave wrote:
Subject: [Jprogramming] Summing odd numbers
To: "programm...@jsoftware.com"
Date: Tuesday, May 15, 2018, 5:29 PM
A simple Quora question wants to know the
formula to sum the first n odd
numbers.
I can write an explicit verb:
smodd
Since you have an even number of verbs in your train (1 and 2 are parsed as
constant 1"_ and 2"_ verbs) the whole is interpreted as a hook, with the
leading +/ taking its dyadic form. Your smodd1 verb is (in its monadic form)
equivalent to
] +/ 1 + 2 * i.
Since you want to apply +/ to the resu
A simple Quora question wants to know the formula to sum the first n odd
numbers.
I can write an explicit verb:
smodd =.3 :'+/1+2*i.y'
smodd 5
25
I want to write a tacit verb:
smodd1=:+/1+2*i.
smodd1 5
6 8 10 12 14
What am I doing wrong?
Skip Cave
Cave Consulting LLC