Task

Take a   Natural Number   in a given base and return the sum of its digits:

   110         sums to   1
   123410   sums to   10
   fe16       sums to   29
   f0e16     sums to   29


#lang transd
 
MainModule : {
    v10: [1, 1234, 10000000],
    vvar: ["fe:16", "f0e:16", "2022:3", "Transd:30"],
 
    sumDigits: (λ s String() 
        (with snum (substr s 0 ":") 
              base (first (substr s after: ":") "10") n 0
        (textout "sum of " :left width: 10 (+ snum ":" base " : " ))
        (tsd (split snum "") :reduce
            using: (λ s String() (+= n (to-Int (+ s ":" base))))) (lout n))
    ),
 
    _start: (lambda 
        (tsd v10 reduce: ["(to-String col1)"] 
                 using: (λ s String() (sumDigits s)))
        (tsd vvar reduce: ["(sumDigits col1)"] )
    )
}