<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Great - thanks!<div><br></div><div>Yours truly,</div><div>David</div><div><br><div><div>On 2012-02-23, at 3:59 PM, mike clemow wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Alternatively, you can implement this will the append operator:<br><br>fun float[] t(float x,float nn[]) {<br><br>    // assign with zero length<br>    float rr[0];<br><br>    for(0 => int n;n<nn.size();n++) {<br>        // append<br>        rr << (nn[n] + x );<br>    }<br>    return rr;<br>}<br><br><<< t(4.5, [7.,8.,9.])[2] >>>;  // should print 13.5<br><br><br><a href="http://michaelclemow.com">http://michaelclemow.com</a><br>http://semiotech.org<br><br><br><br><br>On Thu, Feb 23, 2012 at 3:56 PM, mike clemow <michaelclemow@gmail.com> wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">Yes, ditto to what Kassen said.  (I'm too slow... ;)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">fun float[] t(float x,float nn[]) {<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">    float rr[nn.size()];<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">    for(0 => int n;n<nn.size();n++) {<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">        nn[n] + x => rr[n];<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">    }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">    return rr;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><<< t(4.5, [7.,8.,9.])[2] >>>;  // should print 13.5<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">http://michaelclemow.com<br></blockquote><blockquote type="cite">http://semiotech.org<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Thu, Feb 23, 2012 at 3:45 PM, Kassen <signal.automatique@gmail.com> wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">On Thu, Feb 23, 2012 at 12:27:22PM -0800, Colin Sullivan wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">David,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">I think the problem may be that you are returning an array that is local to<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">your function and it is getting deallocated when the function returns.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">That's what I thought too, and that certainly can happen.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">In that case a extra assignment (using @) can increase the reference<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">count, tricking the simple CC. That's not "good form" just a<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">workaround while some of that stuff is a bit dodgy.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">That's not the issue here though, at least not the primary one. The<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">primary issue here is that rr gets defined without a length and so<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">apparently doesn't get initiated. Editing the relevant line to read;<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> float rr[nn.size()];<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">makes sure all floats are initiated and for my tests it works.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I think the issue is not with returning, the reported error is<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">refering -I suspect- to the moment when we try to chuck the result of<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">the addition to the array location, the error just isn't indicating<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">that, obfuscating what went wrong.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I hope that helps (I also hope it's correct ;-) )<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Yours,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Kas.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">_______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">chuck-users mailing list<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">chuck-users@lists.cs.princeton.edu<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote>_______________________________________________<br>chuck-users mailing list<br>chuck-users@lists.cs.princeton.edu<br>https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br></div></blockquote></div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>-------------------------------------------------------------------</div><div>Dr. David Ogborn, Assistant Professor<br>Communication Studies & Multimedia</div><div>Director, Cybernetic Orchestra & ESP Studio</div><div>McMaster University, Hamilton, Canada<br><br>ogbornd --at-- <a href="http://mcmaster.ca">mcmaster.ca</a></div><div><div><a href="http://davidogborn.net/">http://davidogborn.net</a></div><div><a href="http://twitter.com/ogbornd">http://twitter.com/ogbornd</a></div><div><span class="Apple-style-span" style="font-size: medium; "><a href="http://esp.mcmaster.ca/">http://esp.mcmaster.ca</a> (Cybernetic Orchestra)</span></div></div><div>1-905-525-9140 ext 27603</div></div><div><br></div></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>