[FRPythoneers] Joining a lists of lists?

marciot marciot at holly.colostate.edu
Tue Aug 6 16:06:31 MDT 2002

>If so then something like
>def joinlists(lists):
>  res = {}
>  for l in lists:
>     for v in l:
>        res[v] = 1
>  k = res.keys()
>  k.sort() #optional
>  return k

You mean I actually have to write *code* to do this? Man... :(

>If not, then something like:
>>> t = [[1,2,3],[4,5,6],[7,8,9]]
>>> reduce(lambda x,y:x+y,t,[])

Actually, this looks like what I'm needing. In fact, I was getting close, 
since I had tried "reduce(append,t,[])" but Python complained about the 
'append'. I didn't realize you could use "+" on lists :)

Thanks for your help :)

Marcio Luis Teixeira

PS: If anyone cares, I found a document that seems like might be a good 
tutorial for the LISP inclined: http://www.norvig.com/python-lisp.html . Looks 
like it might make for good reading.

More information about the FRPythoneers mailing list