return gibt falschen wert zurück

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
BlackJack

Auch in Richtung Lisp allerdings näher an Python dran:
[codebox=clojure file=Unbenannt.txt]#!/usr/bin/env hy


(defn flatten [items]
(if (instance? list items)
(let [result []]
(for [item items] (.extend result (flatten item)))
result)
[items]))


(defn flatten! [items]
(let [result []
f (fn [xs]
(if (instance? list xs)
(for [x xs] (f x))
(.append result xs)))]
(f items)
(assoc items (slice None) result)))


(defmain [&rest argv]
(let [egg [3 4 [[5]]]
spam [[[1 2 egg] (, 6 [7]) 8] 9 False]]
(print (flatten egg))
(print (flatten spam))
(flatten! egg)
(print egg)
(print spam)
(flatten! spam)
(print spam)))[/code]
Antworten