Author Topic: DosLib: Explanation of "dos_difference"  (Read 1405 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 654
DosLib: Explanation of "dos_difference"
« on: November 03, 2020, 04:48:23 AM »
The help for dos_difference gives these examples:

Code - Auto/Visual Lisp: [Select]
  1. Command: (dos_difference 10)
  2. -10
  3.  
  4. Command: (dos_difference 10 3 5 8)
  5. -6
  6.  
  7. Command: (dos_difference '(10 3 5 8))
  8. 2
  9.  
  10. Command: (dos_difference '(10 3) '(2 7))
  11. (8 -4)

Example b) is the only one which I understand: 10-3-5-8=-6

But for the other ones I don't see the maths behind it. Who can explain?

Thanks!
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: DosLib: Explanation of "dos_difference"
« Reply #1 on: November 03, 2020, 05:19:30 AM »
Maybe:
Code: [Select]
(dos_difference 10) > (dos_difference 0 10) > -10

(dos_difference '(10 3) '(2 7)) > ((10 - 2) (3 - 7)) >  (8 -4)

(dos_difference '(10 3 5 8)) > ?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DosLib: Explanation of "dos_difference"
« Reply #2 on: November 03, 2020, 05:28:50 AM »
Apparently, if the parameters are lists they should have no more than 3 items:
Code: [Select]
: (dos_difference '(1 2 3 4) '(10 3 5 8))
nil
: (dos_difference '(1 2 3) '(10 3 5))
(-9 -1 -2)
: (dos_difference '(10 3 5))
2
: (dos_difference '(10 3 5 1000))
2

Peter2

  • Swamp Rat
  • Posts: 654
Re: DosLib: Explanation of "dos_difference"
« Reply #3 on: November 03, 2020, 05:50:23 AM »
Great, thanks.

Has one of you contact to the devs on Github to report? Or should I report it?
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Peter2

  • Swamp Rat
  • Posts: 654
Re: DosLib: Explanation of "dos_difference"
« Reply #4 on: November 06, 2020, 05:30:27 AM »
I talked with Dale at Github, and it seem to be the strange behaviour of the Lisp Interpreter, already described here;
https://wiki.mcneel.com/doslib/dos_strformatdate

It seems that ..
- it occurs (only?) in lists with 4 entries
- it can be worked-around with more than 4 entries or
- defining the first value in first list as real and not as integer.

Here my tests:
Code - Auto/Visual Lisp: [Select]
  1. Befehl: (dos_difference '(10 3) '(2 7))
  2. (8 -4)
  3.  
  4. Befehl: (dos_difference '(10 3 20 30) '(2 7 5 6))
  5. nil
  6.  
  7. Befehl: (dos_difference '(10.0 3 20 30) '(2 7 5 6))
  8. (8 -4 15 24)
  9.  
  10. Befehl: (dos_difference '(10 3 20 30 8 9 10 11) '(2 7 5 6))
  11. nil
  12.  
  13. Befehl: (dos_difference '(10 3 20 30 8 9 10 11) '(2 7 5 6 2 3 4 5))
  14. (8 -4 15 24 6 6 6 6)
  15.  
  16. Befehl: (dos_difference '(10 3 20) '(2 7))
  17. nil
  18.  
  19. Befehl: (dos_difference '(10 3 20 30 8 9 10) '(2 7 5 6 2 3 4 ))
  20. (8 -4 15 24 6 6 6)
  21.  
  22. Befehl: (dos_difference '(10 3 20 30 8 9) '(2 7 5 6 2 3))
  23. (8 -4 15 24 6 6)
  24.  
  25. Befehl: (dos_difference '(10 3 20 30 8 ) '(2 7 5 6 2 ))
  26. (8 -4 15 24 6)
  27.  
  28. Befehl: (dos_difference '(10 3 20 30 ) '(2 7 5 6  ))
  29. nil
  30.  
  31. Befehl: (dos_difference '(10.0 3 20 30 ) '(2 7 5 6  ))
  32. (8 -4 15 24)
  33.  
  34. Befehl: (dos_difference '(10.5 3 20 30 ) '(2 7 5 6  ))
  35. (8.5 -4 15 24)
  36.  
  37. Befehl: (dos_difference '(10 3 20 30 ) '(2 7 5.0 6  ))
  38. nil
  39.  
  40. Befehl: (dos_difference '(10 3.0 20 30 ) '(2 7 5.0 6  ))
  41. nil
  42.  
  43. Befehl: (dos_difference '(10.0 3 20 30 ) '(2 7 5.0 6  ))
  44. (8 -4 15 24)
  45.  
  46. Befehl: (dos_difference '(10.0 3 20 30 ) '(2 7 5 6  ))
  47. (8 -4 15 24)
  48.  
  49. Befehl: (dos_difference '(10 3 20 30 ) '(2.0 7 5 6  ))
  50. nil
  51.  
  52. Befehl: (dos_difference '(10.0 3 20 30 ) '(2 7 5 6  ))
  53. (8 -4 15 24)
  54.  
« Last Edit: November 06, 2020, 06:26:27 PM by Peter2 »
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23