Talk:Flatten a list: Difference between revisions

Line 2:
The comment after the CL example seems to imply that it would not work with the example list given, which includes nested lists that contain an empty list. It would therefore not satisfy the task? --[[User:Paddy3118|Paddy3118]] 00:50, 17 August 2009 (UTC)
:It works with the example given. The point is that if your list-of-lists-of-...-of-lists has as one of the intended leaf values ''a list'', you won't get the proper answer. This is true of any flattener, unless you mark the leaves as not-part-of-the-tree somehow. --[[User:Kevin Reid|Kevin Reid]] 02:32, 17 August 2009 (UTC)
::Hi Kevin, The intent is for nests of ultimately empty lists to not appear in the output at all. Doesn't lisp have some operation OP, where:
lista OP listb = lista with the elements of listb concatenated
::And:
lista OP emptylist == lista
::You should be able to complete a solution from that. The Python recursive solution is like that as the OP is list summation where:
[1,2,3] + [4,5,6] = [1,2,3,4,5,6]
::And:
[1,2,3] + [] = [1,2,3]
:::--[[User:Paddy3118|Paddy3118]] 06:35, 17 August 2009 (UTC)
 
==OCaml and Empty lists?==
Anonymous user