Talk:Apply a callback to an array: Difference between revisions

From Rosetta Code
Content added Content deleted
(Task description does not seem accurate.)
(→‎specifying callback: Needs more of a plain English definition)
Line 21: Line 21:


The opening sentence of the Wikipedia [http://en.wikipedia.org/wiki/Callback_%28computer_science%29 entry] is: "In computer programming, a callback is executable code that is passed as an argument to other code." The current task description does not seem to specify that a callback is to be used. ("In this task, the goal is to take a combined set of elements and apply a function to each element.") Just adding the word to this won't work, as we wish to communicate what counts as a callback. --[[User:TBH|TBH]] 07:10, 16 January 2008 (MST)
The opening sentence of the Wikipedia [http://en.wikipedia.org/wiki/Callback_%28computer_science%29 entry] is: "In computer programming, a callback is executable code that is passed as an argument to other code." The current task description does not seem to specify that a callback is to be used. ("In this task, the goal is to take a combined set of elements and apply a function to each element.") Just adding the word to this won't work, as we wish to communicate what counts as a callback. --[[User:TBH|TBH]] 07:10, 16 January 2008 (MST)
:I was never really clear on what a callback is. Is it like a composition operator? --[[User:Mwn3d|Mwn3d]] 19:01, 16 January 2008 (MST)

Revision as of 02:01, 17 January 2008

The problem is, of course, that they're all doing slightly different things. To some extent this is unavoidable due to language differences, but when one example is mapping the results into another array and a different example decides to print them, that's just a bit sloppy. Though I certainly don't mind if you have secondary examples demonstrating different techniques or modifications to the basic premise (such as the c++ use of a binary function).

I wrote up some guidelines, but I need to make them more visible. I'll probably add them to--or link to them from--the programming task template.--Short Circuit 12:46, 23 January 2007 (EST)

array vs list

I was just looking at the Haskell solution for this task, and it uses a list instead of an array. Of course, Haskell has built in arrays, lists are just more natural, as they are in all functional languages. This seems deceptive to me. I know lists are more natural than arrays in Haskell, but it seems to me this page should contain the array example, and an alternate task should be made for lists. Just as Haskell will seem more complicated on the array examples, imperative languages like C will have to use a complicated list structure for the list examples. It doesn't seem right to neglect this distinction. Thoughts? -- Zarvok | Talk 22:45, 23 January 2007 (EST)

I don't know any functional languages. What's the difference between a list and an array? --Short Circuit 23:27, 23 January 2007 (EST)
TCL is almost-functional (it steals a lot from LISP). I'll put an example for either in there. A list is just what the name implies -- essentially what would be called a one-dimensional array in many other languages. It is the natural storage container for a bunch of data in TCL (and indeed was the only data structure for a long time). In TCL, at least, the notion of an "array" strictly implies an associate array. I.e. looping over a list means looping over the elements of the list (and doing something with them), but looping over an array means looping over the keys of the array (and doing something with the elements associated with those keys). Sgeier 18:28, 1 February 2007 (EST)
I still struggle with this differentiation, and what it may imply when providing examples in J, which is one of the languages where "a list" means "an array of one axis (or dimension)". If "list" means a unit of data that lacks any key-reference aspect, then perhaps tasks that specify use of lists should not be completed using J? --TBH 16:36, 15 January 2008 (MST)
My opinion: I interpret this particular task as "Apply a callback to a collection". The array-ness is secondary, it is the callback that is of interest. --IanOsgood 17:11, 15 January 2008 (MST)
Did anybody notice there's no task description? This can all be wrapped with a clarification. Feel free to clean it up. --Short Circuit 21:14, 15 January 2008 (MST)
I agree that the callback aspect is the gist of this task. This place might not be the best for me to have raised my concern. Still, it seems that the list-vs-array specification is part of a pattern of problem that occurs for some languages, under some tasks, which we may want to overcome by refinement of task descriptions. --TBH 21:25, 15 January 2008 (MST)

specifying callback

The opening sentence of the Wikipedia entry is: "In computer programming, a callback is executable code that is passed as an argument to other code." The current task description does not seem to specify that a callback is to be used. ("In this task, the goal is to take a combined set of elements and apply a function to each element.") Just adding the word to this won't work, as we wish to communicate what counts as a callback. --TBH 07:10, 16 January 2008 (MST)

I was never really clear on what a callback is. Is it like a composition operator? --Mwn3d 19:01, 16 January 2008 (MST)