Author Topic: Help me find grammatical and logic errors  (Read 3548 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help me find grammatical and logic errors
« Reply #15 on: January 29, 2017, 11:33:18 AM »
You can always work backwards.

AREA>300000
AREA>100000
AREA>20000
AREA>5000
AREA>1000
AREA>100
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.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Help me find grammatical and logic errors
« Reply #16 on: January 29, 2017, 11:43:04 AM »
The areas will never be exactly equal to an integer value, as a result of reals (doubles) being represented in a computer to a limited precision, and the resulting infinitesimal errors which accumulate when working with such numbers. Therefore if the areas are very close to the condition boundaries, you may want to include some tolerance, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (<= area (+ 100 1e-8))

etc.

pedroantonio

  • Guest
Re: Help me find grammatical and logic errors
« Reply #17 on: January 29, 2017, 11:58:57 AM »
thanks lee

JohnK

  • Administrator
  • Seagull
  • Posts: 10661
Re: Help me find grammatical and logic errors
« Reply #18 on: January 29, 2017, 03:00:30 PM »
it's a test is not something important.I am trying to see were is the error and why is not working.
That is irrelevant; a descriptive subject title will draw more people to read your post and will also help others using the search feature of the forum find an answer to their problem if it is similar to yours. It is a sign of respect; please be more considerate of others by doing as much research, and being as descriptive, as possible.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ChrisCarlson

  • Guest
Re: Help me find grammatical and logic errors
« Reply #19 on: January 31, 2017, 12:47:52 PM »
The code steps down each cond statement. If the variable "area" = 1 then it will return each conditional statement as true.

Code - Auto/Visual Lisp: [Select]
  1.  (<= area 1000) ;; Area greater than 100 & less than or equal to 1,000

Combine it with an and statement

Code - Auto/Visual Lisp: [Select]
  1.  (and (> area 100) (<= area 1000)) ;; Area greater than 100 & less than or equal to 1,000

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Help me find grammatical and logic errors
« Reply #20 on: January 31, 2017, 12:49:25 PM »
The code steps down each cond statement. If the variable "area" = 1 then it will return each conditional statement as true.

Code - Auto/Visual Lisp: [Select]
  1.  (<= area 1000) ;; Area greater than 100 & less than or equal to 1,000

Combine it with an and statement

Code - Auto/Visual Lisp: [Select]
  1.  (and (> area 100) (<= area 1000)) ;; Area greater than 100 & less than or equal to 1,000

No need - cond ceases evaluation of subsequent test expressions when a test expression returns a non-nil value.

ChrisCarlson

  • Guest
Re: Help me find grammatical and logic errors
« Reply #21 on: January 31, 2017, 01:01:10 PM »
Interesting, from a writing standpoint, is it better to rely on cond ceasing as it travels down the list or should one include the specific requirements you want on each test?


As I'm writing this it sounds like 6 of one, half-dozen of another.