Talk:Odd word problem: Difference between revisions

Promotions?
(Promotions?)
 
(3 intermediate revisions by one other user not shown)
Line 1:
== Explanations Promote?==
Is this task now sufficiently clear that we can promote it to full task status? It's certainly got enough implementations, and it's got a short sample text to try it out with too. Are we waiting for anything now? –[[User:Dkf|Donal Fellows]] ([[User talk:Dkf|talk]]) 16:32, 11 May 2014 (UTC)
 
== Explanations ==
Obviously, this task is not about text processing. Rather, it's about conditional code execution order. The even words are straightforward, while reversing odd words are easy with, say, recursion, with the catch that the word end marker (punctuation) needs to be processed ''after'' the recursion has returned. If peeking ahead is allowed, then this difficulty is removed and the whole thing becomes quite moot. --[[User:Ledrug|Ledrug]] 20:06, 3 November 2011 (UTC)
:So this is a modified version of the problem that has been linked to? The solutions there seem to use buffers and peeking a lot. The site also says that the words will be a maximum of 20 characters long. Unless I'm missing changes in the spec later in the discussion, maybe there should be no link at all to that site (just to avoid confusion). --[[User:Mwn3d|Mwn3d]] 20:12, 3 November 2011 (UTC)
Line 24 ⟶ 26:
}</lang> it looks to me exactly like it is buffering a sequence of characters for later reversal. Except, of course, it is not buffering them in an efficient fashion (just storing the characters), instead, it is buffering them as a sequence of some internal data structure that allows code to be resumed. The TCL version must be doing something similar, with coroutines? Except that's still an array, it's just an array of something else. (For that matter a byte is an array of 8 bits...). Anyways, if the point is to use an array of incomplete function executions, I can do that in J. But the architecture would be exactly the same as the architecture I would use for reversing a sequence of characters, except bulkier (both in code, to create the wrapper functions, and execute them, and in data, to store the wrapper functions). And, since it is J, which you do not understand, this would be even harder to understand than a more simpler implementation. That said: <code>RUN=: ] bind 'a'</code> creates verb (a function) <code>RUN</code> which always returns the letter <code>'a'</code>, and <code><nowiki>RUNING=: RUN f.`''</nowiki></code> takes the verb <code>RUN</code> and returns a gerund (which is a noun -- an array, that represents the same concept that the original verb represented) which in this case is the definition of <code>RUN</code> (because <code>f.</code> extracts an anonymous definition from a name). which it saves under the name <code>RUNNING</code>. Or, I could have just done <code><nowiki>] bind 'a'`''</nowiki></code> and gotten a gerund wrapper for the character 'a'. ... anyways, I can build up a list of these and then later on apply J's reverse operator <code>|.</code> and then convert the resulting sequence of gerund to a verb which returns the sequence of results from the represented verbs, and give that verb its argument. In other words:<lang j> (|.] bind 'a'`(] bind 'b')`(] bind 'c'))`:0 ''
cba</lang> ... but I am not avoiding buffering here. I am not avoiding use of arrays. I am doing exactly what was forbidden. I am just wrapping each character with some bulk and then unwrapping it later, after reversing them... do you understand my dilemma now? --[[User:Rdm|Rdm]] 12:30, 5 November 2011 (UTC)''
:::::: ''Oh, and the mandated use of (in this case character-at-a-time) streams (which J does not implement natively, since they are useless (edit: [[Odd_word_problem/TrivialCharacterStreamSupportForJ|worse than useless]]) within the language itself) would add significantly more bulk and require platform dependent code (J does not natively support unbuffered character-at-a-time streams, but it does support dynamically linking to shared libraries...) so any educational value from the illustration of data wrapping/unwrapping would be lost in the noise... --[[User:Rdm|Rdm]] 12:49, 5 November 2011 (UTC)''
::::::: The Tcl version is indeed holding values on the stack (with single assignment, as it happens) but that's explicitly allowed, whereas using an explicit queue or stack data structure would be not allowed. Also note that Tcl doesn't really like char-by-char input either, but it can work. If it's too onerous with J (can it read fixed with binary records, and if it can, can it read a record of size 1?) then that would be a good reason for omitting the task. –[[User:Dkf|Donal Fellows]] 13:53, 5 November 2011 (UTC)
:::::::: J stream input is line at a time, unless, for example, you are using sockets (the socket interface uses predeclared fixed-sized buffers). And, ok, yes, a hands off approach (using the call stack) would avoid using an explicit stack. But that's really still just a buffer... And, meanwhile, if I use sockets, I have to run another program to feed the socket (and that program would itself have to store a buffered string, which defeats the point of not using buffers, as a coding constraint -- why does it have to be a coding constraint and not an interface constraint?). --[[User:Rdm|Rdm]] 17:54, 5 November 2011 (UTC)
Line 66 ⟶ 68:
:# Or sometimes it can be good to state up-front what aspects of the task your language cannot handle before adding an example that doesn't answer the task for just those stated reasons.
:In the second case you shouldn't be surprised if the presence of the example is questioned, marked <nowiki>{{incorrect}}</nowiki>, or even deleted if people think it strays too far from the task description without much gain for the reader. --[[User:Paddy3118|Paddy3118]] 12:19, 7 August 2012 (UTC)
::: I would prefer, however, if those "good tasks" could have non-paradoxical (and unambiguous) task specifications. --[[User:Rdm|Rdm]] 13:23, 7 August 2012 (UTC)
 
Is it time to move this task from draft?
Anonymous user