Hello,
i couldn't find a function in newlisp to limit a value between upper and lower limits.
i.e. something like this:
"return x < some_minimum ? some_minimum : x > some_maximum ? : some_maximum : x;"
Reason is that i'am working a lot with sin, cos and the brothers and i often need to limit my floats for example to precisly -1 or 1.
Thanks and Regards
Heiko
			
			
									
									
						min-max limiter
- 
				TedWalther
 - Posts: 608
 - Joined: Mon Feb 05, 2007 1:04 am
 - Location: Abbotsford, BC
 - Contact:
 
Re: min-max limiter
Code: Select all
(cond ((> x some_max) x_max) ((< x some_min) x_min) (true x))
Code: Select all
(define (bandpass x xmin xmax)
    (cond ((> x xmax) xmax) ((< x xmin) xmin) (true x)))
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  "Abomination!" they cried.
						Re: min-max limiter
sweet.
Thanks a lot for pointing this one out.
			
			
									
									
						Thanks a lot for pointing this one out.