<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Some good ideas. Have you checked out StringTokenizer (strings/token.ck)? It may be helpful to extend that, but implement a .separator(string) variable that uses any string to tokenize rather than only using white space. That would be a start, and regexp could be implemented beginning with that.</div><div><br></div><div>Check out those examples, though--a few of your suggestions are in there (like .trim()). My idea is that many of these could be implemented within ChucK fairly easily without resorting to mangling the source--as long as we had some very basic methods to start from.</div><div><br></div><div>Andrew</div><div><br></div><div><div><div>On Feb 8, 2010, at 12:44 PM, mike clemow wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Some ideas:</div><div><br></div>"this is a string.    ".trim() => string foo; // "this is a string."<div><br></div><div>foo.split(" ") => string[] foos;  // ["this", "is", "a", "string."]</div>
<div><br></div><div>split should take any string--or regex expression, if we can have those.</div><div><br></div><div><div>"hello".endswith("lo") => int boolean;  // 1</div><div><div>"hello".endswith("ll") => int boolean;  // 0</div>
<div><br></div><div><div>"hello".startswith("he") => int boolean;  // 1</div><div><div>"hello".startswith("hi") => int boolean;  // 0</div><div><br></div><div>check if string is a digit</div>
<div><div>"1234".isdigit() => int boolean; // 1</div><div><div>"1s34".isdigit() => int boolean; // 0</div><div><br></div><div>check if string is alpha-numeric</div><div><div>"1234".isalnum() => int boolean; // 1</div>
<div><div>"1s34".isalnum() => int boolean; // 1</div><div><div>"1s-4".isalnum() => int boolean; // 0</div><div><br></div><div>check if string is alpha only</div><div><div>"abc".isalpha() => int boolean;  // 1</div>
<div><div>"2bc".isalpha() => int boolean;  // 0</div><div><div>"-bc".isalpha() => int boolean;  // 0</div><div><br></div><div>Those were ripped off python, which has a lot of good ones.  <a href="http://www.python.org/doc/2.5.2/lib/string-methods.html">http://www.python.org/doc/2.5.2/lib/string-methods.html</a></div>
<div><br></div><div>we might be able to get away with these to start and build more complex ones in there using these, like you said.</div><div><br></div><div>_mike</div><div><br></div><div><br></div></div></div></div></div>
</div></div></div></div></div></div></div></div><div><br><div class="gmail_quote">2010/2/7 Andrew C. Smith <span dir="ltr"><<a href="mailto:andrewchristophersmith@gmail.com">andrewchristophersmith@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div>Hm, yeah, I remember you mentioned preprocessing with Python or something. This is great for what it works for (esp. since you can just write and chuck files straight from Python's shell capabilities) but even just reading a particular character in a string--reading a string as an array of 8-bit chars, for instance--would be great.</div>
<div><br></div><div>If I continue hacking through the string class, what are some useful methods? I saw some of the undocumented string methods like .trim() and a few others (documented in examples/strings/) but those seem like the beginnings of something taken out of the oven a little too early. What would be helpful to have, and how can I make sure that additions are transportable to other builds? Anyone want to test some new methods? With a few very, very simple string methods we could build the rest into the LiCK library.</div>
<div><br></div><font color="#888888"><div>Andrew</div></font><div><div></div><div class="h5"><br><div><div>On Feb 6, 2010, at 4:37 PM, mike clemow wrote:</div><br><blockquote type="cite">Andrew,<br><br>Not that this helps you out or even lends to your argument, but I've been pre-processing my input files so that ChucK can read them easier.  I have a feeling that the file IO for ChucK owes part of its heritage to the processing of SKINI files, which is a Perry Cook thing.  The current IO methods seem to be ideally suited for this purpose. <br>

<br><a href="https://ccrma.stanford.edu/software/stk/skini.html" target="_blank">https://ccrma.stanford.edu/software/stk/skini.html</a><br><br>But I'm with you, man: string parsing / regex stuff is absolutely necessary to make any sort of FileIO worth our while.<br>

<br>Should also be fairly easy to wrap up some basic C++ stuff into Chuck.<br><br>Unhelpfully,<br>Mike<br><br><div class="gmail_quote">2010/2/6 Andrew C. Smith <span dir="ltr"><<a href="mailto:andrewchristophersmith@gmail.com" target="_blank">andrewchristophersmith@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div style="word-wrap:break-word">Hey list, it's been a while.<div><br></div><div>I've got this quick little script for reading in Scala files, and there's a particularly important part of it that goes like this:</div>

<div><br></div><div><div style="margin:0px"><span style="color:rgb(51, 0, 255)">if</span> (scale.more() && scale.read(<span style="color:rgb(232, 146, 0)">1</span>) == <span style="color:rgb(81, 81, 81)">"/"</span>) {</div>

<div style="margin:0px"><span style="color:rgb(51, 0, 255)"><span style="white-space:pre"><font color="#000000">        </font></span>if</span> (scale.more()) {</div><div style="margin:0px"><span style="white-space:pre">            </span>scale.readInt(<span style="color:rgb(232, 146, 0)">1</span>) => den;</div>

<div style="margin:0px"><span style="white-space:pre">  </span>}</div><div style="margin:0px">}</div><div style="margin:0px"><br></div><div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px">Basically, I'm just reading in from the file (FileIO scale) to see if the next character is a slash. If so, it's a ratio and I assume that the next number is the denominator. However, I had to go in and un-comment the whole FileIO.read(int) section in the source code. I haven't had any problems with it and can't figure out why it was commented out. It seems so useful to just read a particular number of characters, but this workaround means that I can't share my code with anyone else very easily.</span></font></div>

<div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px"><br></span></font></div><div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px">Also, we had that wish list going and no one ever said (at least not that I saw) "regular expressions." But, seriously, that would be so helpful for parsing outside information. And I think you all know how much fun it is to pump random outside data through algorithms. I don't exactly see how the FileIO thing is particularly useful unless there's some way of parsing the data.</span></font></div>

<div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px"><br></span></font></div><div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px">What have you all come up with? Is anyone using FileIO? What about a Floss addition? Nice manual, by the way. Good work list.</span></font></div>

<div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px"><br></span></font></div><font color="#888888"><div style="margin:0px"><font face="Helvetica" size="3"><span style="font-size:12px">Andrew</span></font></div>

</font></div></div><br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://michaelclemow.com/" target="_blank">http://michaelclemow.com</a><br><a href="http://semiotech.org/" target="_blank">http://semiotech.org</a><br><br>
_______________________________________________<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div><br></div></div></div><br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://michaelclemow.com/">http://michaelclemow.com</a><br><a href="http://semiotech.org/">http://semiotech.org</a><br><br>
</div>
_______________________________________________<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br></blockquote></div><br></div></body></html>