Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better string handling #102

Open
eholk opened this issue Sep 3, 2013 · 4 comments
Open

Better string handling #102

eholk opened this issue Sep 3, 2013 · 4 comments
Labels

Comments

@eholk
Copy link
Owner

eholk commented Sep 3, 2013

Right now Harlan programs can't do much more with strings than pass them around. Even just adding facilities to convert between C strings and vectors of chars would greatly improve the ability of Harlan programs to manipulate strings.

eholk added a commit that referenced this issue Dec 19, 2013
Added a new unsafe-cast primitive that lets us write conversion functions in the library.
@its2mc
Copy link

its2mc commented Apr 29, 2015

Cool... so how would I access the chars in a string in harlan?

@eholk
Copy link
Owner Author

eholk commented May 5, 2015

There's a function, str->vec, which converts a string to a vector of characters. From there you can use vector-ref to access individual characters. For example:

(let ((v (str->vec "hello")))
  (vector-ref v 0))

That should return the character 'h'.

@its2mc
Copy link

its2mc commented May 6, 2015

Cool.. will try that out when I get time.. I have twitter word analysis in mind.. but lets see how that can work.. :D

@eholk
Copy link
Owner Author

eholk commented May 6, 2015

Sounds like fun!

I've been working on a PLY file loader lately which is forcing me to improve Harlan's string and IO facilities. Hopefully that will help you out too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants