1lambda(n)          Utility commands for anonymous procedures         lambda(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       lambda - Utility commands for anonymous procedures
9

SYNOPSIS

11       package require Tcl  8.5
12
13       package require lambda  ?1?
14
15       ::lambda arguments body ?arg...?
16
17       ::lambda@ namespace arguments body ?arg...?
18
19______________________________________________________________________________
20

DESCRIPTION

22       This  package  provides two convenience commands to make the writing of
23       anonymous procedures, i.e. lambdas  more  proc-like.  Instead  of,  for
24       example, to write
25
26
27                   set f {::apply {{x} {
28                      ....
29                   }}}
30
31       with its deep nesting of braces, or
32
33
34                   set f [list ::apply {{x y} {
35                      ....
36                   }} $value_for_x]
37
38       with a list command to insert some of the arguments of a partial appli‐
39       cation, just write
40
41
42                   set f [lambda {x} {
43                      ....
44                   }]
45
46       and
47
48
49                   set f [lambda {x y} {
50                      ....
51                   } $value_for_x]
52
53

COMMANDS

55       ::lambda arguments body ?arg...?
56              The command constructs an anonymous procedure from the  list  of
57              arguments, body script and (optional) predefined argument values
58              and returns a command prefix representing this anonymous  proce‐
59              dure.
60
61              When  invoked  the  body  is  run  in a new procedure scope just
62              underneath the global scope, with the arguments set to the  val‐
63              ues supplied at both construction and invokation time.
64
65       ::lambda@ namespace arguments body ?arg...?
66              The command constructs an anonymous procedure from the namespace
67              name, list of arguments, body script and  (optional)  predefined
68              argument  values  and returns a command prefix representing this
69              anonymous procedure.
70
71              When invoked the body is run in a new  procedure  scope  in  the
72              namespace, with the arguments set to the values supplied at both
73              construction and invokation time.
74

AUTHORS

76       Andreas Kupries
77

BUGS, IDEAS, FEEDBACK

79       This document, and the package it describes, will  undoubtedly  contain
80       bugs  and other problems.  Please report such in the category lambda of
81       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
82       also  report any ideas for enhancements you may have for either package
83       and/or documentation.
84
85       When proposing code changes, please provide unified diffs, i.e the out‐
86       put of diff -u.
87
88       Note  further  that  attachments  are  strongly  preferred over inlined
89       patches. Attachments can be made by going  to  the  Edit  form  of  the
90       ticket  immediately  after  its  creation, and then using the left-most
91       button in the secondary navigation bar.
92

SEE ALSO

94       apply(n), proc(n)
95

KEYWORDS

97       anonymous procedure, callback, command prefix, currying,  lambda,  par‐
98       tial application, proc
99

CATEGORY

101       Utility
102
104       Copyright (c) 2011 Andreas Kupries, BSD licensed
105
106
107
108
109tcllib                                 1                             lambda(n)
Impressum