[chuck-users] FileIO.read( int ) -- why not implement?

mike clemow michaelclemow at gmail.com
Mon Feb 8 12:44:20 EST 2010


Some ideas:

"this is a string.    ".trim() => string foo; // "this is a string."

foo.split(" ") => string[] foos;  // ["this", "is", "a", "string."]

split should take any string--or regex expression, if we can have those.

"hello".endswith("lo") => int boolean;  // 1
"hello".endswith("ll") => int boolean;  // 0

"hello".startswith("he") => int boolean;  // 1
"hello".startswith("hi") => int boolean;  // 0

check if string is a digit
"1234".isdigit() => int boolean; // 1
"1s34".isdigit() => int boolean; // 0

check if string is alpha-numeric
"1234".isalnum() => int boolean; // 1
"1s34".isalnum() => int boolean; // 1
"1s-4".isalnum() => int boolean; // 0

check if string is alpha only
"abc".isalpha() => int boolean;  // 1
"2bc".isalpha() => int boolean;  // 0
"-bc".isalpha() => int boolean;  // 0

Those were ripped off python, which has a lot of good ones.
http://www.python.org/doc/2.5.2/lib/string-methods.html

we might be able to get away with these to start and build more complex ones
in there using these, like you said.

_mike



2010/2/7 Andrew C. Smith <andrewchristophersmith at gmail.com>

> 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.
>
> 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.
>
> Andrew
>
> On Feb 6, 2010, at 4:37 PM, mike clemow wrote:
>
> Andrew,
>
> 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.
>
> https://ccrma.stanford.edu/software/stk/skini.html
>
> But I'm with you, man: string parsing / regex stuff is absolutely necessary
> to make any sort of FileIO worth our while.
>
> Should also be fairly easy to wrap up some basic C++ stuff into Chuck.
>
> Unhelpfully,
> Mike
>
> 2010/2/6 Andrew C. Smith <andrewchristophersmith at gmail.com>
>
>> Hey list, it's been a while.
>>
>> 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:
>>
>> if (scale.more() && scale.read(1) == "/") {
>>  if (scale.more()) {
>> scale.readInt(1) => den;
>>  }
>> }
>>
>> 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.
>>
>> 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.
>>
>> What have you all come up with? Is anyone using FileIO? What about a Floss
>> addition? Nice manual, by the way. Good work list.
>>
>> Andrew
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>>
>
>
> --
> http://michaelclemow.com
> http://semiotech.org
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>


-- 
http://michaelclemow.com
http://semiotech.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20100208/bd74c329/attachment.html>


More information about the chuck-users mailing list