[plt-scheme] append-map examples

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Sat Apr 10 11:07:55 EDT 2010

Ack! I've been using append-map a lot recently. Granted, I then did
something like remove-duplicates, usually, so I really had a set. But
sometimes not. Here's the use case:

I'm representing SQL statements and have a function that returns a SQL
string with parameter place-holders and a list of parameters,
something like

(list "SELECT * FROM my_table WHERE id=?" (list 4))

except, of course, that the parts "*" and "id=?" could be literals. In
other words, I could have

(list "SELECT ? FROM my_table WHERE id=?" (list "abc" 4))

I guess I could have created a structure with a sql-string and params
part, but I'd still want to append-map the params together to keep
them in the same order as the place-holders. So, is this a licit use
of append-map, or have I strayed?

Todd

On Fri, Apr 9, 2010 at 10:49 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> Dan Friedman once shared a rule with me: when you use append-map, you are using the wrong data representation.
>
> Examples:
>
>
> On Apr 9, 2010, at 10:40 PM, Ryan Culpepper wrote:
>
>> Skeptic . wrote:
>>> Hi,
>>> Does someone knows canonical/pedagogical exemples of append-map except other than flatten ?
>>
>> Collect a list of all the X in a Y.
>>
>> eg, the list of free variables in a lambda term
>
> Free variables come in sets, not lists.
>
>
>> eg, the list of links in a web page (as xexpr or sxml)
>
> Ditto.
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.