J/HouseStyle: Difference between revisions
Content deleted Content added
m Removed inappropriate "header" template |
imported>Katsumi No edit summary |
||
Line 33:
:::I agree with much of what you say - particularly that full descriptions/explanations of the code don't belong on the main task page. However I do think that a slight increase in the verbosity and amount of comments will help decrease the perceived impenetrability of "standard" J solutions.
:::Using the [[Zig Zag]] task as an example, I think something like one of the solutions in your excellent explanation on the Talk page would be both intriguing and more likely to encourage further study by non-J users, than the current solutions. i.e.
<syntaxhighlight lang="j">
</syntaxhighlight>
</lang>▼
:::vs.
<syntaxhighlight lang="j">
</syntaxhighlight>
</lang>▼
:::--[[User:Tikkanz|Tikkanz]] 22:46, 14 October 2009 (UTC)
:::The [[Select]] task is perhaps a better example. Compare the current solution:
<syntaxhighlight lang="j">
load 'misc'
select=: ({::~ 'choose a number 0..' 0&".@prompt@, ': ',~ ":@<:@# [ i.@# smoutput@,&":&> ' '&,&.>) :: (select@([ smoutput bind 'please choose a valid number'))
</syntaxhighlight>
</lang>▼
::: to a slightly more verbose one:
<syntaxhighlight lang="j">
load 'misc'
displayMenu =: i.@# smoutput@,&":&> ' '&,&.>
Line 58:
select=: ({::~ _&".@prompt@(makeMsg [ displayMenu)) :: ($:@displayBadNumMsg)
</syntaxhighlight>
:::As a relatively fluent tacit J user, the first version took a little while to come to grips with if for no other reason than because it was so long. --[[User:Tikkanz|Tikkanz]] 02:02, 16 October 2009 (UTC)
Line 86:
If I'm reusing names from other tasks or the [[j:Essays|J wiki]], I will directly link to them here. Otherwise there will be no lede or introduction.
'''Solution''':
'''Solution''':<lang j>name =: a succinct but legible definition NB. Possibly references other defined names, ▼
<pre>
NB. as Tikkanz showed, where each name encapsulates a single,▼
name =: a succinct but legible definition
NB. but powerful thought. No trivial names.▼
▲
'''Alternative solution (''style'')''':
<pre>
NB. For example, explicit as opposed to tacit. ALWAYS lead with the preferred▼
name =: alternative, equivalent solution in a different style
NB. (usually shortest) solution; alternative solutions are merely showcases. ▼
NB. Note also that the exact same name is assigned, indicating all solutions▼
NB. are identical, and could equally be the referent of the Example section. ▼
NB. Do not present too many solutions; keep the J entry short and sweet. ▼
NB. Further solutions can always be linked to.</lang>▼
'''Example''':
'''Example''': <lang j>name argument NB. Example usages; exercise all the interesting aspects, ▼
<pre>
NB. particularly "free" extensions and generalizations ▼
name argument
NB. which are unavailable in the other languages.</lang>▼
'''Discussion''': Very brief, high-level overview of how the solution works (e.g. mentions the heart of the solution is a built-in J <code>primitive</code>), with an optional [[Talk:J/HouseStyle#J|embedded link]] to a fuller explanation or exposition on the Talk: page.
|