Talk:Vocabulary/fcap

From J Wiki
Jump to navigation Jump to search

Add comments here on any glitches on this page.


Conform to familiar NuVoc layout

Coming back to NuVoc (almost) as a newcomer, I was baffled by the structure of this page. It has departed significantly from its original layout. Once upon a time it was more like other NuVoc pages, which have these clearly recognizable sections in the order shown:

  • Header
  • rank ¶
  • What It Does: ideally in a single simple sentence
  • What It Does: a supporting code sample (straightforward and tested) ¶
  • Common Uses §
  • More Information (below a heavy line warning the beginner to stop reading) §
  • ...

I've provided items flagged (¶) and fixed the layout to expose familiar landmarks.

The essay-type preamble / rationale / (whatever…) is idiosyncratic for a NuVoc page, lapsing into a scheme resembling an ancillary page. It sure needs its TOC – which a NuVoc page typically does not. I'd like to round it off and make it clearer what it is, also dig out from it the standard sections marked (§).

But I've done only what I consider vital for a newcomer, viz. Header down to What It Does (inclusive). I've let the remainder be for now. You can argue anything below Common Uses (of which there are too many, some better described as Creative Uses) can be as woolly as you like, as far as a beginner is concerned. Ian Clark (talk) 01:34, 2 March 2022 (UTC)

…oh, and the diagram is too big. Suggest shrink it to 70% Ian Clark (talk) 01:39, 2 March 2022 (UTC)

I love the resized diagram with its side comments. They nicely withstand narrowing the window. Ian Clark (talk) 23:45, 2 March 2022 (UTC)

Thinking about it some more, it's clear to me the whole "rationale" should be moved into an Ancillary Page, called (say) Designing the operands for Fold (F. F: etc). This stuff is only of interest to someone trying to use Fold in-depth, not someone who's simply come across it in a script and wants to know roughly what it's doing.

Only (shortened) standard sections should remain here. Ian Clark (talk) 02:25, 2 March 2022 (UTC)


I agree. I plan to reorganize the page soon into the streamlined NuVoc style and break off the rationale and tutorial-oriented stuff into a separate page unless others happen to do so first.

Also the unlimited folds currently get scant and dispersed attention in the page, making it exceedingly difficult to reason about their use cases. They should get a separate section that briefly describes their workings in one place, like the organization of the Power of Verb page into sections on Converge / Dynamic If / DoWhile etc.

Further, the unlimited folds would benefit from comparison with the {{u^:v^:_}} and {{u^:v^:a:}} constructs, as they're basically heavier-duty versions powered by the additions of Z:'s fine-grained breaking/continuing behavior and u's optional post-processing. But this change would add to the mess if done prior to reorganizing the page. --Cameron Chandoke (talk) 19:29, 11 October 2023 (UTC)

Splitting content out from the current revision of this page sounds like a good target. --Raul Miller (talk) 13:05, 12 October 2023 (UTC)

Broken link

Re: More Information (item #3)

[[Vocabulary#Neutral|neutral]] is a broken link with macOS Safari. Ian Clark (talk) 00:44, 2 September 2019 (UTC)


Examples

Fold single examples:

Forward (dyad): 0 U F.. V 2 3 4 is equivalent to U 4 V 3 V 2 V 0 Reverse: U F.: V 2 3 4 is equivalent to U 2 V 3 V 4

is U@V , else Z: in U would be ineffective.

Forward (dyad): 0 U F.. V 2 3 4 is equivalent to 4 U@V 3 U@V 2 U@V 0 Reverse: U F.: V 2 3 4 is equivalent to 2 U@V 3 U@V 4 --David Lambert (talk) 15:06, 1 March 2022 (UTC)

I am getting this:
     {{_1 Z: 1}} F.: {{ x,y[echo x,y }} 2 3 4 5 6
  5 6
  4 5 6
  3 4 5 6
  2 3 4 5 6
  |domain error
So I expect Z: in U for fold single is not supported. I will update the page. --Raul Miller (talk) 15:57, 1 March 2022 (UTC)

Z: in u for Fold Single is indeed supported; it's just that a domain error results when no u-results have been added to the overall result by the time that the Fold terminates. So in the example above, this happened because every u-result was rejected. as the y-argument to Z: was 1 unconditionally in every iteration.

   {{y[_2 Z: 4=#y}} F.: {{ x,y[echo '    ',":x,y }} 2 3 4 5 6
    5 6
    4 5 6
    3 4 5 6
4 5 6

However I didn't notice where the page says that u in Fold Single isn't supported. So maybe this was already corrected...? --Cameron Chandoke (talk) 18:51, 11 October 2023 (UTC)


Use of U instead of u, V instead of v, puzzled me. I suppose you want to emphasize these are instantiated verbs, not placeholders inside some explicit definition. But I think the subtlety is lost on a beginner. IMO better to keep to the standard NuVoc notation for operands in a code example.

I've changed the inline code examples accordingly. Revert if I'm off-beam. Ian Clark (talk) 02:14, 2 March 2022 (UTC)

Fold Forward/Reverse rather than Fold Left/Right

Fold Left/Right is both shorter and more familiar from other functional langs.

The page says to note “…that we use "forward" and "reverse" here because left to right in terms of the fold's y argument would be different from J's right to left evaluation order.“

I’m baffled by this rationale. Yes it would be different, but why should J’s evaluation order be relevant to the semantics of Fold at all? If we called it Fold Left/Right, what confusion would this potentially cause? --Cameron Chandoke (talk) 18:22, 12 October 2023 (UTC)

I suspect that a part of that line of thinking was rooted in thoughts about the / adverb, which is very similar to a fold, and which is documented as inserting a verb between items of an array (and, thus, implicitly depending on how J parses expressions). But another more immediate issue is that left and right also correspond to arguments of the combining verb used in the fold (but also, to the arguments to the fold conjunction where the combining verb is the right verb). But another issue would be that "left" could mean "from the left" but it could also mean "towards the left", and either of those could refer to order of execution or order of hierarchy (top-to-bottom or bottom-to-top - bottom-to-top matching order of execution). Anyways.. using "left" and "right" as labels here seems like an ambiguity reduction which only works after the ambiguity has been resolved. --Raul Miller (talk) 18:49, 12 October 2023 (UTC)
Right. Because of this issue of evaluation order, I'd say that, while the "insert the verb between y-items" is appropriate for the J's particular Insert adverb, it is inappropriate for describing general "fold" (in any lang, not just J). Separately, I'd be surprised if the presence of left/right operands, or left/right arguments to Fold or its operands, caused anyone confusion relating to the name Fold Left. There would still be a description that clearly tells the meaning of Fold Left/Right, at which point the semantic is is easily understood.
Among those given, I see the "starting side vs. direction" as the one realistic potential source of confusion / [misremembering semantics]. This one yields to an argument for the current semantics, although I see either as being reasonable. --Cameron Chandoke (talk) 21:27, 12 October 2023 (UTC)

u and/or v being ringed

Regarding the Fold diagram's accompanying side text, which says u and v must/should be ringed:

Rings have two binary operations, but u is unary, while v is binary.

It looks to me like there no algebraic constraints apply to either u or v, besides that v's domain must be closed under v (not sure if there's an algebraic term for this; but, not to my knowledge). The same does not apply to u since u takes, as input, a v-result, not a u-result.

Will remove the note about rings in the meantime; please revert and explain if I'm misunderstanding something here. --Cameron Chandoke (talk) 23:00, 12 October 2023 (UTC)

Yeah... in U F.. V, V should be a group, but that's probably about as far as that kind of reasoning should be taken. (And there's technically an exception in the sense that V only has to be a group in context of the argument(s) to the derived verb. V might be a non-group in some other context - basically, if it throws an error, then the derived verb would also throw an error for that example.) --Raul Miller (talk) 02:03, 13 October 2023 (UTC)