Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List Comprehension Library for Scheme?

I know there is a list-comprehension library for common lisp (incf-cl), I know they're supported natively in various other functional (and some non-functional) languages (F#, Erlang, Haskell and C#) - is there a list comprehension library for Scheme?

incf-cl is implemented in CL as a library using macros - shouldn't it be possible to use the same techniques to create one for Scheme?

like image 224
Kyle Burton Avatar asked Sep 25 '08 01:09

Kyle Burton


People also ask

What is list comprehension used for?

List comprehension is an elegant way to define and create lists based on existing lists. List comprehension is generally more compact and faster than normal functions and loops for creating list. However, we should avoid writing very long list comprehensions in one line to ensure that code is user-friendly.

What is list comprehension method?

List comprehension offers a shorter syntax when you want to create a new list based on the values of an existing list. Example: Based on a list of fruits, you want a new list, containing only the fruits with the letter "a" in the name.

What is list comprehension what is its advantage?

One main benefit of using a list comprehension in Python is that it's a single tool that you can use in many different situations. In addition to standard list creation, list comprehensions can also be used for mapping and filtering. You don't have to use a different approach for each scenario.


1 Answers

  • Swindle is primarily a CLOS emulator library, but it has list comprehensions too. I've used them, they're convenient, but the version I used was buggy and incomplete. (I just needed generic functions.)
  • However, you probably want SRFI-42. I haven't used it, but it HAS to have fewer bugs than the Swindle list comprehensions.

I don't know which Scheme you use. PLT Scheme bundles Swindle and SRFI-42. Both are supposed to be cross-Scheme compatible, though.

If you use PLT Scheme, here is SRFI-42's man page. You say (require srfi/42) to get it.

like image 172
Nathan Shively-Sanders Avatar answered Sep 30 '22 19:09

Nathan Shively-Sanders