Unknown function operation deciphering, exercise in readability by program reasoning
small Pox
smallpox911 at gmail.com
Sun Dec 5 13:03:33 EST 2010
On Dec 4, 11:37 pm, Madhu <enom... at meer.net> wrote:
> * jvt <5e1f79ab-5432-4f18-b896-362b7406c... at i18g2000yqn.googlegroups.com> :
> Wrote on Sat, 4 Dec 2010 19:34:53 -0800 (PST):
>
> |
> | I think this is correct:
> |
> |
> | (defun unknown-function (sym0)
> | (let (sym1 sym2)
> | (while (or sym2 sym0)
> | (if sym0
> | (if (consp sym0)
> | (setq sym2 (cons (cdr sym0) sym2) sym0 (car sym0))
> | (setq sym3 sym4 (cons sym0 sym1) sym0 nil))
> | (setq sym0 (car sym2) sym2 (cdr sym2))))
> | sym1))
> | Thank emacs, not me.
>
> Not quite. You didn't account for the original poster's go-
> ogle masters mangling his message. But your function appears to be a
> list flattener:
explanation
> (defun unknown-function (list)
> (let (stack ret)
> (while (or ret list)
> (if list
> (if (consp list)
> (setq ret (cons (cdr list) ret) ;; hint: this is a push followed by
list (car list)) ;; pop
> (setq stack (cons list stack) ;; and so is this
list nil))
> (setq list (car ret) ret (cdr ret))))
> stack))
>
> ---
> Madhu
I will post an explanation in a few days if no one does this before
since its not urgent for anyone and i have some job assignments to
finish.
More information about the Python-list
mailing list