Author Topic: Symbol(s)'s value(s)  (Read 5621 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10666
Re: Symbol(s)'s value(s)
« Reply #15 on: May 10, 2018, 08:40:57 AM »
Ha! I have kids so finding/remembering where "goofy" or the "little lightning McQueen car" is every two seconds must have helped.

I hope that procedure isn't the only thing of his you've read. The man is gifted. In fact, I remember seeing a thread where he gave a solution to store lists of data in xrecords of the dwg file (I'm sure he did something similar to this in that task so there's a common thread in there somewhere). The man's code inspired so much; just reading a thread or function would inspire so many ideas -e.g. after reading one of his functions you learned that you could use a simple function like IF in a whole new way. I've posted at least one full program of his (or at least one that I've pieced together/fixed/etc). I think it was a bench-marking/profiling tool.

Glad my bumbling lead to something better.


...

That looks/reminds me of a procedure by Vladimir Nesterovsky. ...I studied his code quite a bit (a wonderful programmer)!

The procedure handles the nested lists because it's recursive.

You have a good memory, John - :thumbsup_emoji:
Right after I ended writing & testing the subfoo it reminded me of V.Nesterovsky's safearray value subfoo, which basically has the same algorithm..
Well atleast we have another use of it in our pocket.


I wonder if the top most eval (line 4) is needed in the first procedure because of how COND works (of course, please excuse my mistake if I'm wrong; still a bit rusty).

Good thought, at first I tried just a wrap of: (eval (cdr (assoc (type ... )))) , but then I realised that I won't be able to do an else statement,
unless I don't fill in all the variable types i.e.: INT/REAL/STRING/VARIANT/OBJECT... etc, as additional cases - so then I implemented the cond.
But now you mention it - eval is required only to evaluate the result from the quoted list, so more effective version of it would be:

Code - Auto/Visual Lisp: [Select]
  1. (defun symval ( symval:x )
  2.   (cond
  3.     (
  4.       (eval
  5.         (cdr
  6.           (assoc (type symval:x)
  7.             '(
  8.               (SYM . (symval (vl-symbol-value symval:x)))
  9.               (LIST . (mapcar 'symval symval:x))
  10.             )
  11.           )
  12.         )
  13.       )
  14.     )
  15.     ( symval:x )
  16.   )
  17. ); defun symval
  18.  

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org