Talk:Forward difference: Difference between revisions

delete remark 'verb fd'
(No point in signalling error conditions.)
(delete remark 'verb fd')
 
(7 intermediate revisions by 5 users not shown)
Line 7:
:The formula given '''Bn = An+1 - An''' only applies to lists of two or more elements. It could be argued that it is more correct to signal an error condition when given a list of less than two elements to work on.--[[User:Paddy3118|Paddy3118]] 04:42, 27 August 2008 (UTC)
::There are differences of opinion as to how best to handle input that does not lie within the domain of a function. My inclination is to (1) rely entirely on the error-reporting facilities of the programming environment, when possible, and (2) use a separate function to assure conformance of the input with the function, when necessary. In the case of forward difference we should also consider whether there is specific value to avoiding the definitional extensions that allow these functions to succeed when provided single-valued or empty lists. In the absence of a larger problem context I cannot see any benefit from producing error conditions instead of empty lists. --[[User:TBH|TBH]] 18:50, 27 August 2008 (UTC)
:::Any 'extension' behaviour should be carefully noted if you rely on it which means you should know what this behaviour is, and that you rely on it. In this specific case I think it would be incorrect to produce a forward difference from an input list of one value. It is more correct to signal an error (with a meaningful explanation).
:::If your function was guaranteed to be called in such a way that you would never be called on to produce a forward difference of less than two values then no further checks need be done, but I think its wrong to argue that the forward difference of one value is an empty list just because a particular implementation would generate that - unless you extend ''your'' meaning of forward difference explicitly to handle this. --[[User:Paddy3118|Paddy3118]] 21:53, 27 August 2008 (UTC)
::::Except for those Rosetta Code tasks that specifically involve error-trapping, code solutions should assure that correct results are produced when the program is provided "good" input. Your claim is that input other than a numeric list of at least length two does not count as good. When the input is not good it is irrelevant what the code produces. Error reporting such as you have suggested has nothing to do with the task at hand. --[[User:TBH|TBH]] 18:21, 28 August 2008 (UTC)
:::::Which makes this whole section irrelevant! :-) --[[User:Paddy3118|Paddy3118]] 20:02, 28 August 2008 (UTC)
:I believe that it is completely mathematically consistent for the forward difference of a list of one element to be the empty list. For one thing, you can see that the forward difference of a list is usually a list one shorter; so the forward difference of a list of length 1 should be a list of length 0; i.e. the empty list. Also, a reasonable definition of forward difference is (the list without the first element) - (the list without the last element), where the "-" is an element-by-element subtraction of the sublists. In the case of the list of one element, both of those sublists are empty, and the result is the empty list. Now, I agree that the forward difference of an empty list should be an error, because it fails both of my above arguments (what is a list of length -1?). --[[User:Spoon!|Spoon!]] 19:09, 28 August 2008 (UTC)
::One shorter? Check! But your reasonable definition is an ''alternative'' definition whose output differs in this case under discussion. It would be better just to state what a forward difference of a list with one member should be - and so exclude one of the definitions, or, state that good input excludes this case. (Or delete the whole section from the talk page and pretend that all is well :-) --[[User:Paddy3118|Paddy3118]] 20:02, 28 August 2008 (UTC)
 
It is very nice to see the [[Python]] entry. Studying it has improved my grasp of that language. --[[User:TBH|TBH]] 09:45, 11 January 2008 (MST)
Line 12 ⟶ 18:
== J: verb vs adverb ==
 
With regard to the replacement of '''<tt>((}. - }:) ^:)</tt>''' by '''<tt>(2&(-/\))</tt>''':
I agree that a solution in the form of a verb is somewhat better than a solution that is an adverb, although the benefits strike me as subtle and minor.
I think the original solution is worth retaining as an example because of its form. It is not only a different algorithm, it is another strong example of how tacit form allows one to "code the concept." These two solutions complement one another, so both should be included.
Line 59 ⟶ 65:
 
[[User:DanBron|DanBron]] 23:01, 26 August 2008 (UTC)
::Thank you for elaborating on why it is beneficial to code this as a verb, rather than as an adverb. It is always nice to get explanation for a correction.
::As for which algorithm is a more "natural" or elegant expression, it seems like one of those tough calls. I'm sure my bias was merely a function of what I happened to learn first. Over time I may well come to prefer the version that relies on Infix. I do now concede that is is significantly better because it produces a verb. --[[User:TBH|TBH]] 19:07, 27 August 2008 (UTC)
Anonymous user