<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: explain subfunction in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823305#M51309</link>
    <description>There's always the (atom ...) function which requires a quoted symbol.&lt;BR /&gt;(and (atom (quote lst))(listp lst)) ; maybe?&lt;BR /&gt;Or just (= (type lst) 'LIST) ;; Not good enough&lt;BR /&gt;Therefor:&lt;BR /&gt;(defun really_a_list (lst)&lt;BR /&gt;  (and (= (type lst) 'LIST)(vl-list-length lst))&lt;BR /&gt;)&lt;BR /&gt;Command: (really_a_list '()) nil&lt;BR /&gt;Command: (really_a_list 2) nil&lt;BR /&gt;Command: (really_a_list '(62 . 5)) nil&lt;BR /&gt;Command: (really_a_list '(2 3)) T</description>
    <pubDate>Tue, 14 Dec 2021 22:28:46 GMT</pubDate>
    <dc:creator>john.uhden</dc:creator>
    <dc:date>2021-12-14T22:28:46Z</dc:date>
    <item>
      <title>explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10819935#M51300</link>
      <description>&lt;P&gt;hi everyone,&lt;/P&gt;&lt;P&gt;kindly explain this subfunction(i got it from leemac website). I understand this subfunction is removing duplicate items, but I don't know how it's working. what does working which I red marked? it too confusing for me. why he put it into this "&lt;FONT face="arial black,avant garde"&gt;&lt;FONT color="#FF0000"&gt;LM:Unique" &lt;FONT color="#000000"&gt;inside function.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;(defun LM:Unique ( l ) (if l (cons (car l) &lt;FONT color="#FF0000"&gt;(LM:Unique&lt;/FONT&gt; (vl-remove (car l) (cdr l)) ) ) ) )&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 16:19:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10819935#M51300</guid>
      <dc:creator>thsa2501</dc:creator>
      <dc:date>2021-12-13T16:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10820024#M51301</link>
      <description>&lt;P&gt;This is recursive function, a function that calls itself and his technique is known as recursion.&lt;/P&gt;
&lt;P&gt;LM:UNIQUE&amp;nbsp; repeats in the way that it creates new list consisting of&amp;nbsp; first element in a list (car l) combined with the&amp;nbsp; result of function vl-remove running over rest of the list (cdr l). It runs as long function parameter returned is a list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here you have another way to create unique list&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun unique (lst)(if (and (and lst)(listp lst))(vl-remove-if '(lambda (x)(member x (setq lst (cdr lst)))) lst)))&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;Command: (unique '(1 2 3 3 3 4))
(1 2 3 4)
Command: (unique '(1 (2 3) (2 3) 3 3 4))
(1 (2 3) 3 4)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Dec 2021 16:45:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10820024#M51301</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-12-13T16:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822662#M51302</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like it, but I'm missing something...&lt;/P&gt;
&lt;P&gt;Why did you use member instead of vl-position?&lt;/P&gt;
&lt;P&gt;It's not as though you were avoiding vl* functions.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 16:50:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822662#M51302</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2021-12-14T16:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822910#M51303</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There was no particular reason for using function member, so vl-position can be used instead.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 18:53:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822910#M51303</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-12-14T18:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822990#M51304</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;....&amp;nbsp;&lt;/SPAN&gt;Why did you use member instead of vl-position? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you want to know whether an item is a member of a list,&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (member) &lt;/FONT&gt;&lt;/STRONG&gt;is the obvious function.&amp;nbsp; &lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;(vl-position)&lt;/FONT&gt;&lt;/STRONG&gt; may be faster as you have pointed out before, but the difference would be meaningless unless you have a large number of such lists to uniquify all at once.&amp;nbsp; Neither returns anything directly usable for the task at hand except in that both returns are&amp;nbsp;&lt;STRONG&gt;not nil&lt;/STRONG&gt; if the item is in the list -- either way of getting that will do the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I wonder about is this part:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;... (if (and (and lst) (listp lst)) ...&lt;/LI-CODE&gt;
&lt;P&gt;Why&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;(and&lt;/STRONG&gt;&lt;/FONT&gt; lst&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;)&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;?&amp;nbsp; Wouldn't this serve the purpose?&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;... (if (and lst (listp lst)) ...&lt;/LI-CODE&gt;
&lt;P&gt;[It's curious that you can't just do:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;... (if (listp lst) ...&lt;/LI-CODE&gt;
&lt;P&gt;but that's not sufficient to know that 'lst' exists, because for whatever reason,&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (listp nil) &lt;/FONT&gt;&lt;/STRONG&gt;returns&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;T&lt;/FONT&gt;&lt;/STRONG&gt;.]&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 19:35:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10822990#M51304</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-12-14T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823061#M51305</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;LI-CODE lang="general"&gt;... (if (listp lst) ...&lt;/LI-CODE&gt;
&lt;P&gt;but that's not sufficient to know that 'lst' exists, because for whatever reason,&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (listp nil) &lt;/FONT&gt;&lt;/STRONG&gt;returns&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;T&lt;/FONT&gt;&lt;/STRONG&gt;.]&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...so what you can do is ... (if (vl-consp lst) ...&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 20:10:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823061#M51305</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-12-14T20:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823067#M51306</link>
      <description>I think his fingers were stuttering.&lt;BR /&gt;Yes, nil is also a list of zero items.&lt;BR /&gt;What boggles my mind is the purpose of dotted pairs.&lt;BR /&gt;Yes, they are technically a list, but you can't always treat them as you&lt;BR /&gt;would a conventional list.&lt;BR /&gt;&lt;BR /&gt;Command: (listp '(1 . 4))&lt;BR /&gt;T&lt;BR /&gt;&lt;BR /&gt;Command: (setq a '(0 . "LINE"))&lt;BR /&gt;(0 . "LINE")&lt;BR /&gt;&lt;BR /&gt;Command: (listp a) T&lt;BR /&gt;&lt;BR /&gt;Command: (length a) ; error: bad list: "LINE"&lt;BR /&gt;&lt;BR /&gt;Command: (nth 0 a) 0&lt;BR /&gt;&lt;BR /&gt;Command: (mapcar 'print a)&lt;BR /&gt;0 ; error: bad list: "LINE"&lt;BR /&gt;&lt;BR /&gt;Command: (apply '+ a) ; error: bad argument list tail: "LINE"&lt;BR /&gt;&lt;BR /&gt;Command: (setq b '(1 . 2))&lt;BR /&gt;(1 . 2)&lt;BR /&gt;&lt;BR /&gt;Command: (apply '+ b) ; error: bad argument list tail: 2&lt;BR /&gt;&lt;BR /&gt;Command: (foreach x a (print x))&lt;BR /&gt;&lt;BR /&gt;0 ; error: bad argument type: consp "LINE"&lt;BR /&gt;&lt;BR /&gt;Command: (apply 'max b) ; error: bad argument list tail: 2</description>
      <pubDate>Tue, 14 Dec 2021 20:12:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823067#M51306</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2021-12-14T20:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823085#M51307</link>
      <description>But vl-consp doesn't differentiate a list from a dotted pair...&lt;BR /&gt;Command: (vl-consp '(1 . 3))&lt;BR /&gt;T&lt;BR /&gt;&lt;BR /&gt;Command: (vl-consp '(1 2 3))&lt;BR /&gt;T&lt;BR /&gt;&lt;BR /&gt;But this will...&lt;BR /&gt;Command: (vl-list-length '(1 . 3))&lt;BR /&gt;nil&lt;BR /&gt;&lt;BR /&gt;Command: (vl-list-length '(1 2 3))&lt;BR /&gt;3</description>
      <pubDate>Tue, 14 Dec 2021 20:20:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823085#M51307</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2021-12-14T20:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823173#M51308</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;....&lt;BR /&gt;But this will...&lt;BR /&gt;Command: (vl-list-length '(1 . 3))&lt;BR /&gt;nil&lt;BR /&gt;Command: (vl-list-length '(1 2 3))&lt;BR /&gt;3&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But getting back to the task at hand, that won't suffice by itself to know that 'lst' &lt;EM&gt;exists&lt;/EM&gt; as well as being a list, because non-existence is still a list with no items in it, similar to the result from&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (listp)&lt;/FONT&gt;&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;Command: (vl-list-length nil)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not&lt;FONT face="courier new,courier"&gt; &lt;STRONG&gt;&lt;FONT color="#000000"&gt;T&lt;/FONT&gt;&lt;/STRONG&gt; &lt;/FONT&gt;as&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (listp) &lt;/FONT&gt;&lt;/STRONG&gt;returns, but &lt;EM&gt;not nil, either&lt;/EM&gt;.&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#000000"&gt; (vl-consp) &lt;/FONT&gt;&lt;/STRONG&gt;at least makes that determination in one function, even if it can't tell a list from a dotted pair.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 21:08:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823173#M51308</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-12-14T21:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823305#M51309</link>
      <description>There's always the (atom ...) function which requires a quoted symbol.&lt;BR /&gt;(and (atom (quote lst))(listp lst)) ; maybe?&lt;BR /&gt;Or just (= (type lst) 'LIST) ;; Not good enough&lt;BR /&gt;Therefor:&lt;BR /&gt;(defun really_a_list (lst)&lt;BR /&gt;  (and (= (type lst) 'LIST)(vl-list-length lst))&lt;BR /&gt;)&lt;BR /&gt;Command: (really_a_list '()) nil&lt;BR /&gt;Command: (really_a_list 2) nil&lt;BR /&gt;Command: (really_a_list '(62 . 5)) nil&lt;BR /&gt;Command: (really_a_list '(2 3)) T</description>
      <pubDate>Tue, 14 Dec 2021 22:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823305#M51309</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2021-12-14T22:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823958#M51310</link>
      <description>&lt;P&gt;hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you so much for your reply. I completely understand now.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 06:36:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10823958#M51310</guid>
      <dc:creator>thsa2501</dc:creator>
      <dc:date>2021-12-15T06:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: explain subfunction</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10824331#M51311</link>
      <description>&lt;LI-CODE lang="general"&gt;... (if (and (and lst) (listp lst)) ...&lt;/LI-CODE&gt;
&lt;P&gt;This is just the way of writing test I picked up in 35 years of programming&lt;/P&gt;
&lt;P&gt;If we are sure that function parameter is a list then testing is not needed.&lt;/P&gt;
&lt;P&gt;In lisp we can write&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(if l)&lt;/LI-CODE&gt;
&lt;P&gt;One of my professors at informatics faculty has stated "for easier code readability don't leave lone parameter, but try to show what you ask". So instead I sometime write (if (and l)).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 10:12:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explain-subfunction/m-p/10824331#M51311</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2021-12-15T10:12:46Z</dc:date>
    </item>
  </channel>
</rss>

