Author Topic: Deconstructing Lists  (Read 2953 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Deconstructing Lists
« Reply #15 on: June 09, 2005, 10:37:37 AM »
Hold on.
That doesn't wash with me.
Confused as usual.

Using apply like this
(apply 'Return_Same_Items lst)
is equivalent to
(Return_Same_Items (car lst))
(Return_Same_Items (cadr lst))

Or I am I totally nuts. :)

I thought your subroutine expected two arguments?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17686
  • Have thousands of dwgs to process? Contact me.
Deconstructing Lists
« Reply #16 on: June 09, 2005, 10:40:24 AM »
Close.

(apply 'Return_Same_Items lst)

Is equivalent to --

(Return_Same_Items (car lst) (cadr lst))

Let's now consider which is better --

(/ number 2.0) versus (* number 0.5)

Discuss.
Engineering Technologist CAD Specialist Programmer Analyst
Design Drafting Document Control Automation.
cadanalyst@fastmail.com https://cadanalyst.slack.com http://linkedin.com/in/cadanalyst

whdjr

  • Guest
Deconstructing Lists
« Reply #17 on: June 09, 2005, 11:10:41 AM »
Isn't that kinda like 'a glass half full' and 'a glass half empty'.

 :lol:

MP

  • Seagull
  • Posts: 17686
  • Have thousands of dwgs to process? Contact me.
Deconstructing Lists
« Reply #18 on: June 09, 2005, 11:12:15 AM »
Ding ding ding!

(Though it's bereft any optimism context).
Engineering Technologist CAD Specialist Programmer Analyst
Design Drafting Document Control Automation.
cadanalyst@fastmail.com https://cadanalyst.slack.com http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Deconstructing Lists
« Reply #19 on: June 09, 2005, 11:43:20 AM »
OK so I'm crazy, but i did figure it out with your help. :)
Just wanted to see if i could do it with an indirect function call.

Code: [Select]
(DEFUN XYZ (A1 A2)
  (+ a1 a2)
)

(defun split (fun arg)
  (if (= (length arg) 2)
    (apply fun arg)
    (prompt "\n**  Error in data - expected list of two items")
  )
)

(defun c:test ()
  (split 'XYZ (list 3 5))
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.