Jump to content

String interpolation (included): Difference between revisions

Added more general multi-field interpolation function for APL
(APL example)
(Added more general multi-field interpolation function for APL)
Line 631:
s
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>
 
67

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.