On 2020-10-19 7:51 pm, Dave Seidel wrote:
More succinct:

#(begin
  (use-modules (guile-user))

  (if (not(defined? 'part))
    (define partName "")
    (define partName (string-append "S" (number->string part)))
  )
)

To be even more succinct, observe the following:

====
Avoid negated predicates by swapping the consequent and alternate.
;;;;
(if (defined? 'part)
    (define partName (string-append "S" (number->string part)))
    (define partName ""))
;;;;

====
Extract common logic from consequent and alternate.
;;;;
(define partName
  (if (defined? 'part)
      (string-append "S" (number->string part))
      ""))
;;;;

====
Use formatted output instead of manual string conversion/concatenation.
;;;;
(define partName
  (if (defined? 'part)
      (format #f "S~d" part)
      ""))
;;;;


-- Aaron Hill

Reply via email to