String interpolation (included): Difference between revisions

Content added Content deleted
(APL example)
(Added more general multi-field interpolation function for APL)
Line 631: Line 631:
s
s
Mary had a little lamb
Mary had a little lamb

∇r ← s sInterp sv
⍝⍝ \brief A multi-field string interpolation function
⍝⍝
⍝⍝ \param[⍺] - format string
⍝⍝ \param[⍵] - vector of strings to interpolate into s
⍝⍝ ]return r - interpolated string
⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
s[('_'=s)/⍳⍴s] ← ⊃¨sv
r ← ∊s
'Mary had a _ lamb, its fleece was _ as _.' sInterp 'little' 'black' 'night'
Mary had a little lamb, its fleece was black as night.
</lang>
</lang>