Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Functional programming with ports

Name: Anonymous 2013-02-16 6:03

I was wondering whether there are any kewl libraries for Scheme that have map/fold/unfold-like procedures that work with ports.

Name: Anonymous 2013-02-16 6:09

Name: Anonymous 2013-02-16 6:29

>>2
Hmm, I can't seem to find any on either of those websites. Do you have any recommendations?

Name: Anonymous 2013-02-17 0:23

>>3
ports read and write serialized data. A read only port can look like a function that is called and spits out objects. Every time it is called, it's state is changed, and it will will return different values. Unless caching is used, there it no way to save its prior state.

A writing port acts like a function that takes a single argument and doesn't return a value. It's a black hole. Values go into the function in some order, and nothing comes back out.

Name: Anonymous 2013-02-17 3:10

>>4
Seems like an unfold-like procedure would work well for writing data to ports, a fold-like procedure for reading data from ports, and a map-like procedure for reading and writing data to ports.

There are common operations like reading from a port, char by char, performing some transformation on the char, then writing it to another port, that could easily be generalised with a map or for-each-like procedure.

Name: Anonymous 2013-02-17 5:18

>>5
Yeah, I've found recursive functions to be good. It depends a lot of what you are doing. Some examples are, a database, writing and reading for a given file format, sending and receiving messages over a network. In each domain the complex part is at a level higher than just dealing with the port itself, so their abstractions become more specific to the application than generic file io.

Don't change these.
Name: Email:
Entire Thread Thread List