Jump to content

Named parameters: Difference between revisions

Added PicoLisp
(Added C++ example.)
(Added PicoLisp)
Line 418:
e1 e2
k1 k2</pre>
 
=={{header|PicoLisp}}==
PicoLisp uses normally positional parameters, but
'[http://software-lab.de/doc/refB.html#bind bind]' can be used
to establish bindings to passed names.
===Passing symbol-value pairs===
<lang PicoLisp>(de foo @
(bind (rest) # Bind symbols in CARs to values in CDRs
(println 'Bar 'is Bar)
(println 'Mumble 'is Mumble) ) )
 
(foo '(Bar . 123) '(Mumble . "def"))</lang>
===Passing a name list followed by values===
<lang PicoLisp>(de foo @
(bind (next) # Save all symbols in first argument
(mapc set (arg) (rest)) # then bind them to remaining arguments
(println 'Bar 'is Bar)
(println 'Mumble 'is Mumble) ) )
 
(foo '(Bar Mumble) 123 "def")</lang>
Output in both cases:
<pre>Bar is 123
Mumble is "def"</pre>
 
=={{header|PowerShell}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.