Talk:Forward difference: Difference between revisions

response to TBH
(Older version of J solution should be retained, along with the new solution.)
(response to TBH)
Line 14:
7
--[[User:TBH|TBH]] 21:13, 20 August 2008 (UTC)
:Yep, both solutions could be retained. I'll put the orig back in a moment. To address your specific comments:
 
:I actually think that <tt>2 -/\ y</tt> is a clearer expression of the concept of forward differences. That is, I think of a forward difference as "inserting a <tt>-</tt> between each pair of numbers", and it takes a moment for me to realize that's equivalent to subtracting the curtail from the behead. I just want to tell J "insert a <tt>-</tt> between each pair of numbers", which is exactly what <tt>2-/\y</tt> does.
 
:Of course, this is entirely subjective: it depends on the way you think about the problem. So you may think of "forward differences" exactly as "subtracting the behead from the curtail". In fact, I think some of the other languages calculate their results exactly that way, so the original solution may serve better as a "direct translation".
 
:Regarding verbal vs adverbal: I don't think the differences are minor (though they may be subtle). The most compelling difference I see is that <tt>2&(-/\)</tt> is how you would code the simple forward difference (i.e. as a monad). The fact that it works as a dyad to produce the <tt>N</tt><sup>th</sup> forward difference (for any <tt>N</tt>), without a single change, really highlights J's value as a notation. Put another way, I find it pleasant that monad is the dyad with an implicit left argument of <tt>1</tt>, which is the "normal use case".
 
:A secondary (but still important) difference is generality: Verbal solutions can be easily extended with rank, but it's difficult to slice-and-dice arguments to adverbs. For example, how would you recreate this result using the original solution?
(3 2 3) 2&(-/\)"_1 ?. 3 5 $ 10
16 _20 0
16 _14 11
_17 22 0
 
:With regard to length, my metric was <tt>#</tt> rather than <tt>#@;:</tt>, as in :
#'(}.-}:)^:'
9
#'2&(-/\)'
7
 
:I chose <tt>#</tt> because the comment on the solution specifically highlighted succinctness, and total length is the metric of succictness for the solution's target audience (i.e. developers unfamiliar with J, who we're trying to impress).
 
[[User:DanBron|DanBron]] 23:01, 26 August 2008 (UTC)
Anonymous user