Rosetta Code talk:Village Pump/Suggest a programming task: Difference between revisions

Line 28:
 
:: I know Modula-3 and Ada both have assertion pragmas. I believe OCaml/F# have assertion commands. Oberon-2 has an ASSERT builtin command. I'd say it's "universal" enough that there should at least be libraries for basic assertions in all languages. --01:12, 4 February 2009 (UTC)
 
== Gamma function and similar ==
 
What should it happen when one asks for a "function"/algorithm which is already implemented in a language, in its "standard libs/functions...", or which is implemented in a external extra lib? Should one just show its usage, or show how it would be implemented if the language wouldn't have that function?
 
It seems it strongly depends on how the task was written, but doubts and shadows remain to me; examples:
 
* The Gamma function exists in Fortran2008; if the task asks just ''show how to compute the Gamma function in your language'', I surely would use the intrinsic function, or well known libraries (Python numpy/scipy e.g.). If the task asks for a specific algorithm...? I suppose I am ''forced'' to implement it forgetting about libraries and intrinsics.
* [[Basic bitmap storage]]... Perl uses the Imlib2; it achieves the aim of the task (providing a graphics framework for other related tasks?), but it does not show how in Perl you would create a basic bitmap storage...
* [[Bresenham's line algorithm]] ... Perl again... Imlib2 has its own draw_line routine... since here the task asks explicitly for the implementation of a specific algorithm for drawing lines, cannot we use ''intrinsics'' if any? This time, Perl both shows how to use the Imlib2 and implements the Bresenham algorithm... what if the task would have been ''show how to draw a line using the basic bitmap storage from This Other Task''?
* [[LZW compression]] ... I've not uploaded my C version because it is long since I had to implement a Dictionary and a String facility (so it was easy to translate the Java code...); then I've found the Judy lib (used in [[Creating an Associative Array]]), but I haven't adapted the code yet, nor I am sure Judy can fit the specific need directly (I should anyway write support functions). But in this case, since the algorithm requested by the task is LZW, not Dictionary (or associative arrays, for which there's another task), using heavily extern functions/libraries is ok... except if we use a ''liblzw'' that with a simple <tt>lzwcompress(in, out)</tt> resolve the task...?
 
'''Maybe a moral''': if the task is written in a rather ''general'' way (like: ''show how to draw a line'', ''show how to compute the Gamma function in your language'' and so on), then it seems you can use everything you can, even implement a well-known/used algorithm. If the task asks explicitly for the implementation of an algorithm (Bresenham, LZW, Lanczos approximation...), then we must implement it, disregarding just "details" (e.g.: Bresenham needs to plot single points, we can use any function we can/want to plot them; LZW needs associative arrays, and we can use any already made function/method/object ... and so on)
 
(Middle point: a task could be permissive: ''show how to draw a line, e.g. using the Bresenham algorithm or the Xiaolin Wu algorithm'', but it would be better in this case if the task is separated, since the former just draws a ''sharp line'', the latter draws an ''antialiased line'')
 
Is this The Interpretation we should follow? --[[User:ShinTakezou|ShinTakezou]] 14:14, 24 February 2009 (UTC)