post-increment proposal

For the Compleat Fan
Locked
Dmi
Posts: 408
Joined: Sat Jun 04, 2005 4:16 pm
Location: Russia
Contact:

post-increment proposal

Post by Dmi »

Possible it would be nice to have in native library post-increment versions of (inc) and (dec), which will return value as was before incrementing?
Something like:

Code: Select all

(define (inc-p symb num)
  (let (old (eval symb))
    (if num (inc symb num) (inc symb))
    old))

> (setq i 2)
2
> (inc-p 'i)
2
> i
3
WBR, Dmi

Locked