Talk:Odd word problem: Difference between revisions

m
m (added a couple of <nowiki> to protect some code)
Line 13:
::: If the task really intends "no saving in an array" that makes the Omit/J I placed on this one even more appropriate. In J, "array" is the same thing as "memory" or "storage" or "register" -- there just isn't anything else, in J. But I would still like to make sense of the task, if that is possible. (And, right now, I have to admit that the task does not make sense to me -- especially the one about how one is not supposed to reverse the string.) --[[User:Rdm|Rdm]] 17:48, 4 November 2011 (UTC)
:::: I don't know how to better describe it other than "making order of executation flexible." Maybe it's best to infer it by examples, just take a look at the <code>defer</code> in second Go example and coroutines in the TCL one. --[[User:Ledrug|Ledrug]] 18:46, 4 November 2011 (UTC)
:::::: ''So... I took a look at the go example <lang go>odd := func() byte {
for {
b := byte_in()
Line 22:
}
panic("impossible")
}</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) 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... do you understand my dilemma now?'' --[[User:Rdm|Rdm]] 12:30, 5 November 2011 (UTC)
::::: I really do not know what you mean by "making order of execution flexible" -- it seems to me that you are doing exactly the opposite? Moreover, you earlier stated that you are explicitly trying to make the problem difficult -- but that strikes me as the essence of bad design? Anyways, I am not seeing the point or the gist, here. --[[User:Rdm|Rdm]] 22:03, 4 November 2011 (UTC)
6,951

edits