Hurrah! Finally, someone else who knows LISP! Alas, I fear you'll find we are an endangered species these days (especially around here! haha), but I cant wait to see some LISP-based ODK tooling
You're not alone. There are a few of us old farts around who know lisp...although in my case I haven't used it in 15 years or more so it's more accurate to say "knew".
I believe the world would probably be a better place if we solved all our problems recursively...
I think we already are!....but the stack limit is set too restrictive so gives the behavior of repeating the same mistakes again and again. Perhaps we should request the UN to allocate more memory and increase the stack limit.
Don't you make all your calls tail recursive and/or have an interpreter with tail call optimization?!
In a past life, I taught high schoolers functional programming concepts in Scheme (Lisp dialect) and they really enjoyed it (course page for the curious)! And I've also taught algebra in Racket (Scheme-derived) to middle schoolers with the excellent Bootstrap curriculum. So it's not dead yet.
Cool!!! I likewise taught a course around Scheme, at Vassar. Its pretty awesome to teach functional programming to a bunch of open minds that haven't yet been utterly indoctrinated with the procedural programming paradigm, eh! Alas, these days it seems to be all about teaching the latest flavor-of-the-month website programming language (for which I've yet to see any make extensive use of recursive function calls... sigh).
OK guys (and gals), and in the spirit of The Big Bang Theory... I'll buy a beer for the first person who responds explaining what x actually does!
(defun x (e l) (cond ((null l) (cons e '())) (t (cons (car l) (x e (cdr l)))) ) )
[and no cheating using lisp-online ]
Unfortunately I'm living in Africa right now and all I get is "invalid option" when I try tail recursion. Perhaps the government hasn't invented that yet here.
One of the coolest things I learned in college was functional programming (scheme, fp and lisp) which served as a pathway toward parallel and distributed computing. It felt so freeing and opened up new ways of thinking about (and optimizing) computations. It felt like when you go from 2D to 3D, or from B&W to color. Suddenly new possibilities exist where before you couldn't see them.
Now, to your lisp problem, I nearly sprained my brain looking at this one. It's been so long! It looks to me like it's concatenating lists e and l?
Close, but no cigar. So the beer is still up for grabs folks!
Hint, from CAR and CDR:
the expression (car (cons x y)) evaluates to x, and (cdr (cons x y)) evaluates to y... the car operation returns the first element of the list, while cdr returns the rest of the list.
I just want to confirm that I haven't given up on that beer, or the new found cigar that you mentioned. I'll come back to this but have been swamped with farmer payment and insurance issues at the end of this season and then will be able to really dust the cobwebs off and make a run at the frosty beverage competition.