author | copyright | version |
---|---|---|
RickBarretto |
public domain |
1.0.0 |
This module provides you a sugar-syntax for GCC's anonymous functions.
int max = lambda(int, (int a, int b), { return (a > b)? a:b; });
int max = ʄ(int, (int a, int b), { return (a > b)? a:b; });
int max = ʎ(int, (int a, int b), { return (a > b)? a:b; });
lambda(type, args, body) type: macro
Note: it's not C compilant, but GCC compilant, it's currently using two extended features from GCC:
- nested functions
- statement expressions
type
: the returned typeargs
: the arguments, enclosed by parentesis (()
)- note that colon (
,
) is needed between parameters. body
: the body of the function, enclosed by curly braces ({}
)- note that you must use semi-colon (
;
) for each statement and may need usereturn
if some value is returned.
- note that you must use semi-colon (
ʄ
ʎ
This readme and test.c
are under Public Domain,
while the implementation itself (lambda.h
) is under MPL 2.0.
This file covers the usage and API of
lambda.h
.The current version is covered on Markdown's metadata, and must be synced with the implementation.
Any copyright is dedicated to the Public Domain. https://creativecommons.org/publicdomain/zero/1.0/