Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Fast search pairing algorithm
« Last post by well20152016 on Today at 08:09:06 pm »
Code - Auto/Visual Lisp: [Select]
  1. (setq l1(list (list '(89 1)'(99 3)'(45 4)'(67 7)'(54 5)'(33 3)) "A"))
  2. (setq l2(list (list '(39 1)'(33 9)'(27 1)'(84 8)'(13 7)'(99 5)) "B")
  3. Result:
  4.       (setq l3 (list (list '('(99 3)'(33 3)) "A")
  5.                         (list '('(99 5)'(33 9)) "B")
  6.       ))
2
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by Grrr1337 on Today at 05:32:52 pm »
That's very kind of you to say, but don't be so down on yourself

I'm more like impressed on what you guys can do in this forum (so I'm trying to learn whatever I possibly can).

your programming abilities have already improved significantly over the last few months since you started participating on the forums

I guess that once you get to know any programming language + doing alot of experiments and practice (which are results of high interest) the results are shown...
And then you can get a brief idea of what this language is capable of, so one could give inputs with his ideas about helpful functions (obviously you've been through all of this).

But ofcourse the learning process is not everything.. the tutoring part is (or the good explaining guys are) very important.
Just imagine if in every different programming language there was a Lee Mac guy helping you out with C++/VBA/Ruby/Python...
Its no secret about your huge impact over LISP.

In other words when I attempt to write any decend code in private and I get stuck somewhere in an unknown area,
ofcourse at first I google for a solution... what do I find? - similar question/issue by user X which years ago is solved by Lee Mac.
Then I spend some time to investigate Lee's code to understand or learn something new - so I end up with aside experiment codes where I learned more than I've expected.
Although for some this might sound like a annoying painful process with too much effort, I know that most of you guys here know what is to be driven by your own interest to explore even more in this LISP world.

and so with continued study & practice, there's no reason why you can't continue to progress. :-)

Well with that  trace call  you just revealed how such complex iterations/recursions can be visualised, so that shall be my small step of another adventure. :)
Like I previously mentioned, a I'm a NP++ user, that visualises in his head how the code runs (evaluation by evaluation)
and if stuck - just check the doubtful evaluations in VLIDE's console. So you know that didn't used any other advantages from VLIDE.

I always thought can I impress one of the best LISPers with any code(s) and ended up with progress.  :-D
atleast this idea boosted some motivation
3
I think I made it . Instead of trying to access the properties of each block (and change the properties Scale X , Y , Z)  ,  I tried accessing the block itself and scale it with AutoCAD's SCALE command !
First I select all the desired objects (this is no big deal) :
Code: [Select]
( setq BlocksOnLayerPOINT  ( ssget "X" ( list ( cons 0 "INSERT" ) ( cons 8 "POINT" ) ) ) )Then I tried the foreach function in order to scale each object based on its insertion point :
Code: [Select]
( foreach element BlocksOnLayerPOINT
    ( command "SCALE" element "" ( cdr ( assoc 10 ( entget element ) ) ) 0.5 )
    ( setq index ( + index 1 ) ) )
The problem is that the entget function needs names and not the entinities themselves .
So I tried the while function :
Code: [Select]
( setq index 0 )
( while ( < index ( sslength BlocksOnLayerPOINT ) )
    ( command "SCALE" ( ssname BlocksOnLayerPOINT index ) "" ( cdr ( assoc 10 ( entget ( ssname BlocksOnLayerPOINT index ) ) ) ) 0.5 )
    ( setq index ( + index 1 ) ) )

Finally it works !  :-)
4
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by ronjonp on Today at 04:15:03 pm »
Code - Auto/Visual Lisp: [Select]
  1. (nestedlistlevel_rjp '(("(1") "2" "3"))

Code - Auto/Visual Lisp: [Select]
  1. (nestedlistlevel_rjp '(((1) (2) (3))))

 ;)
I figured it was a bust :) .. just a quick one for the data set provided.
5
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by Lee Mac on Today at 04:12:22 pm »
Lee, the second one is outstanding! :-o
As I understood,
First you dig into the levels and then the recursion 'exits out'
by comparing each pair of lists (where the more nested has a higher priority for the max function [due the sum of the increasing 1+ increment]).

Thank you Grrr1337 - the recursion is perhaps best demonstrated by a trace call:
Code - Auto/Visual Lisp: [Select]
  1. _$ (foo '(("A")((((("B")))))("C")))
  2. 5
Code - Auto/Visual Lisp: [Select]
  1. Entering (FOO (("A") ((((("B"))))) ("C")))
  2.  Entering (FOO ("A"))
  3.    Entering (FOO nil)
  4.    Result:  0
  5.  Result:  0
  6.  Entering (FOO (((((("B"))))) ("C")))
  7.    Entering (FOO ((((("B"))))))
  8.      Entering (FOO (((("B")))))
  9.        Entering (FOO ((("B"))))
  10.          Entering (FOO (("B")))
  11.            Entering (FOO ("B"))
  12.              Entering (FOO nil)
  13.              Result:  0
  14.            Result:  0
  15.            Entering (FOO nil)
  16.            Result:  0
  17.          Result:  1
  18.          Entering (FOO nil)
  19.          Result:  0
  20.        Result:  2
  21.        Entering (FOO nil)
  22.        Result:  0
  23.      Result:  3
  24.      Entering (FOO nil)
  25.      Result:  0
  26.    Result:  4
  27.    Entering (FOO (("C")))
  28.      Entering (FOO ("C"))
  29.        Entering (FOO nil)
  30.        Result:  0
  31.      Result:  0
  32.      Entering (FOO nil)
  33.      Result:  0
  34.    Result:  1
  35.  Result:  5
  36. Result:  5

Even if I had the thought just for the idea I would be unable to write it correctly.
Actually now I see that in your both codes you are able to avoid to pass an index variable.
(BTW such complex subfunctions hint themselves about their author, even if its not mentioned)

That's very kind of you to say, but don't be so down on yourself - your programming abilities have already improved significantly over the last few months since you started participating on the forums, and so with continued study & practice, there's no reason why you can't continue to progress. :-)
6
.NET / USB Flash write protect
« Last post by FELIX on Today at 04:02:02 pm »
Is it possible to make a read-only flash drive to protect against write or delete programmatically?
7
AutoLISP (Vanilla / Visual) / USB Flash write protect
« Last post by FELIX on Today at 04:01:24 pm »
Is it possible to make a read-only flash drive to protect against write or delete programmatically?
8
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by Grrr1337 on Today at 03:49:37 pm »
Lee, the second one is outstanding! :-o
As I understood,
First you dig into the levels and then the recursion 'exits out'
by comparing each pair of lists (where the more nested has a higher priority for the max function [due the sum of the increasing 1+ increment]).

Even if I had the thought just for the idea I would be unable to write it correctly.
Actually now I see that in your both codes you are able to avoid to pass an index variable.
(BTW such complex subfunctions hint themselves about their author, even if its not mentioned)
9
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by Lee Mac on Today at 03:47:26 pm »
Another, RJP-style :-)

Code - Auto/Visual Lisp: [Select]
  1. (defun foo ( l / n r x )
  2.    (setq l (vl-string->list (vl-prin1-to-string l)) r 0 n -1)
  3.    (while (setq x (car l))
  4.        (cond
  5.            (   (= 34 x) (setq l (member 34 (cdr l))))
  6.            (   (= 40 x) (setq n (1+ n)))
  7.            (   (= 41 x) (setq r (max n r) n (1- n)))
  8.        )
  9.        (setq l (cdr l))
  10.    )
  11.    r
  12. )
10
AutoLISP (Vanilla / Visual) / Re: Find the nest level of a list
« Last post by Lee Mac on Today at 03:28:03 pm »
Thanks Grrr1337  :-)

Here's another:
Code - Auto/Visual Lisp: [Select]
  1. (defun foo ( l )
  2.    (cond
  3.        (   (/= 'list (type l)) 0)
  4.        (   (listp (car l)) (max (+ 1 (foo (car l))) (foo (cdr l))))
  5.        (   (foo (cdr l)))
  6.    )
  7. )
Pages: [1] 2 3 ... 10