От: | kov_serg | ||
Дата: | 14.05.18 16:10 | ||
Оценка: |
Делаем виртуальнкю функцию, которая принимает лямду как параметр и в зависимости от того совпала она с предыдущим значением которое передавали в эту функциюMichael L. Scott, Programming Language Pragmatics, 3-rd ed., ELSEVIER 2011
ISBN 13: 978-0-12-374514-9
Page:154
3.6.2 First-Class Values and Unlimited Extent
In general, a value in a programming language is said to have
first-class status if it can be passed as a parameter, returned from a subroutine, or assigned into a variable.
Simple types such as integers and characters are first-class values in most programming languages.
By contrast, a
“second-class” value can be passed as a parameter, but not returned from a subroutine or assigned into a variable,
and a
“third-class” value cannot even be passed as a parameter.
struct A {
lambda prev;
virtual lambda fn( lambda a ) {
if (a==prev) return []{ one };
prev=a;
return []{ two };
}
};
struct A {
int prev;
virtual int fn(int a) {
if (a==prev) return 1;
prev=a;
return 2;
}
};
char r = flag ? (double) char(65) : (double) char(48);