String interpolation (included): Difference between revisions
m
→{{header|APL}}
m (→{{header|APL}}) |
m (→{{header|APL}}) |
||
Line 632:
Mary had a little lamb
⍝⍝⍝ Or, for a more general version which interpolates multiple positional arguments
⍝⍝⍝ handle both string and numeric types...
∇r ← s sInterp sv
Line 639 ⟶ 640:
⍝ sv: vector - vector of items to interpolate into s
⍝ 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.
'Mary had a _ lamb, its fleece was _ as _.' sInterp 'little' 'large' 42
Mary had a little lamb, its fleece was large as 42.
</lang>
|