[commodity-utilities] simplify gnc:uniform-commodity?

old code was confusing; returns non-#f if either of following is true:
- elts is null list
- elts is 1-element list
  and report-commodity is a member of this 1-element list

change to much more intelligible code
This commit is contained in:
Christopher Lam 2019-01-09 08:55:47 +08:00
parent eab4eecac8
commit c045e7c5ec

View File

@ -1032,9 +1032,7 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
(define (gnc:uniform-commodity? amt report-commodity)
;; function to see if the commodity-collector amt
;; contains any foreign commodities
(let ((elts (amt 'format (lambda (comm amt) comm) #f)))
(or (null? elts)
(and (null? (cdr elts))
(member report-commodity
elts
gnc-commodity-equiv)))))
(let ((list-of-commodities (amt 'format (lambda (comm amt) comm) #f)))
(or (null? list-of-commodities)
(and (null? (cdr list-of-commodities))
(gnc-commodity-equiv report-commodity (car list-of-commodities))))))