The tacit version is (usually but not always) a little faster, and IMO
immensely harder to maintain.
My recommendation is to write tacit verbs only for functions that have a
clear spec that will never change. Use explicits for everything else,
i. e. 95% of your code.
And write at least 1 line of commentary for every 8 words of J.
Henry Rich
On 7/7/2018 8:19 PM, Skip Cave wrote:
Ah! Thanks S H! That is what I was looking for:
] f1 =. 13 : '+/ ! >: 2 * i. y'
] ([: +/ [: ! [: >: 2 * i.)
So the named tacit function would be:
f1=.[:+/[:![:>:2*i.
I had a hard time figuring out where to put in the caps ([:) in the tacit
verb.
If that's the case, I might as well just use the explicit definition:
f =.3 :'+/!>:2*i.y'
f 1
1
f 2
7
f 5
368047
Is there any advantage to the pure tacit version, f1?
Skip
On Sat, Jul 7, 2018 at 7:01 PM S H Makdisi <[email protected]> wrote:
As far as I understand, the rationale comes from the way J parses its
sentences, as explained in section E of the dictionary
(http://www.jsoftware.com/help/dictionary/dicte.htm).
When you assign a name to a verb, and the parser then runs into that name,
it
has to be considered as a valid verb, not as a sequence of symbols.
However, when you're assigning the tacit verb, you can instead use the '13
:'
definition to generate your tacit verb:
] f =. 13 : '+/ ! >: 2 * i. y'
[: +/ [: ! [: >: 2 * i.
f 5
368047
If I am programming quickly i will often use '13 :' to define verbs before
going back and optimizing them.
It is important however to learn the use of cap ( [: ) in a verb train, so
as
not to rely on the interpreter to do the heavy lifting of writing the
program,
rather than running it.
[2018-07-07 17:06]
part text/plain 1873
Hmmm.. parentheses are automatically added when I assign a name to a
verb!
What is the rationale for always adding parentheses when assinging a name
to a verb? It seems to be unnecessarily complicating a simple process.
In any case, what method can I use to remove those parentheses, or at
least
nullify their effect, when assiging a name?
Skip
On Sat, Jul 7, 2018 at 4:12 PM Henry Rich <[email protected]> wrote:
Assigning to a name adds an implied set of parentheses. Thus if you
write
f =. +/!>:2*i.
When you execute
f 5
you will get the same result as if you had executed
(+/!>:2*i.) 5
Try it and see.
Henry Rich
On 7/7/2018 5:07 PM, Skip Cave wrote:
I have a tacit verb that finds the sum of the factorials of the odd
integers from 1 to 2n - 1:
+/!>:2*i.1
1
+/!>:2*i.2
7
+/!>:2*i.3
127
+/!>:2*i.4
5167
I want to assign that tacit verb a name f:
f=. +/!>:2*i
f 1
2
f 2
3 3
f 3
4 4 4
f 4
5 5 5 5
My tacit verb doesn't work the same when I assign it a name. How do I
modify the verb to allow me to name it? Why do I have to change my
verb,
just because I assign it a name?
Skip
Skip Cave
Cave Consulting LLC
----------------------------------------------------------------------
For information about J forums see
http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
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