Talk:Longest string challenge: Difference between revisions

→‎Not pointless: more on comparisons and math restrictions (as have been the last few updates)
(→‎Not pointless: more on comparisons and math restrictions (as have been the last few updates))
Line 56:
:: Well, the <code>cmp</code> function doesn't contain arithmetic operators is not the same as the code uses no arithmetics. <code>&p[1]</code> is taking address of the next element of pointer <code>p</code>, i.e. <code>p + 1</code>. And <code>if (p)</code> is the same as <code>if (p != 0)</code>, so one may argue if that contains comparison operator: it certain contains comparison ''operation''. If these are allowed, because pointers can be converted to integers, there really isn't any restriction on arithmetics now: you can increment p by &p[1] and decrement it by &p[-1], you can compare it to zero, then you can do addition and subtraction; with those you can do mulplication and division; if you work hard enough you can probably get a whole math library in there. --[[User:Ledrug|Ledrug]] 19:57, 13 August 2011 (UTC)
::: Thanks for the explanation, my rusty old C memory had it about half figured out. Now while there is admittedly an end of string comparison and pointer advancement happening, I think this passes the spirit of the task. The implicit end of string test is a != comparison for a very specific purpose and the addressing is implicitly moving through a string. Looking at the solutions posted to the Unicon TWiki, automatically advancing a character was fine but if someone used s[p+1] it was considered in violation of the intent. --[[User:Dgamey|Dgamey]] 05:33, 14 August 2011 (UTC)
::: Also, Icon is implicitly advancing a cursor (&pos) inside the string scanning/matching which strikes me as equivalent to what is happening inside of cmp. --[[User:Dgamey|Dgamey]] 06:04, 14 August 2011 (UTC)
 
==Icon uses boolean datatypes==
Anonymous user