Jump to content

Talk:Odd word problem: Difference between revisions

m
added a couple of <nowiki> to protect some code
m (added a couple of <nowiki> to protect some code)
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 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,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.