Arc Forumnew | comments | leaders | submitlogin
1 point by cooldude127 6055 days ago | link | parent

the parenthesis means you have a list nested in a list.


1 point by globalrev 6055 days ago | link

yes and i dont want to, is there a way to get around this.

(car '(( 1 2)) and have ( returned. u cant do some trick here?

(car'("(" + 1)) returns "(", how do i get rid of the ""?

-----

4 points by kens 6055 days ago | link

If you want to display a string without the quotes, use "disp" instead of "write".

If you want to convert a string into an S-expr, use "read", and then if you want to evaluate that expression, use "eval".

  (eval (read "(cons (cons 1 2) 3)"))
But I'm pretty sure you don't want to do either of those in this case. If what you want is nested lists, generate the nested lists - Lisp is good at that. Don't try to piece together your code out of parentheses. The following code will more-or-less generate the nested lists you asked about:

  (def xw (n)
    (let l '()
      (for x 1 n
        (= l (join 'w/link (list l))))
      l))
However, the other problem with your approach is that even if you get xv working, it will pass a quoted expression to defop instead of an expression, and defop won't work right. To generate code, you need a macro, not a function. Here's a macro that will solve your original problem:

  (mac xw args
    (if (is (len args) 1)
          `(pr ,@args)
          `(w/link (xw ,@(cdr args)) (pr ,(car args)))))

  (defop wc req (xw "Wel" "come" "to" "Sweden" "!"))

-----

2 points by conanite 6055 days ago | link

are you looking for something like

  (prn (list #\( 'foo #\)))

?

-----