shrub/jets/f/ut_peel.c

56 lines
1.1 KiB
C
Raw Normal View History

2016-10-28 03:26:40 +03:00
/* j/6/ut_peel.c
2015-12-27 07:39:38 +03:00
**
*/
#include "all.h"
/* logic
*/
u3_noun
2016-10-28 03:26:40 +03:00
_cqfu_peel(u3_noun van,
2015-12-27 07:39:38 +03:00
u3_noun sut,
u3_noun way,
2015-12-27 07:58:07 +03:00
u3_noun met)
2015-12-27 07:39:38 +03:00
{
2015-12-27 07:58:07 +03:00
if ( c3__gold == met ) {
return u3nc(c3y, c3y);
2015-12-27 07:39:38 +03:00
}
2015-12-27 07:58:07 +03:00
else switch ( way ) {
default: return u3m_bail(c3__fail);
2015-12-27 07:39:38 +03:00
2015-12-27 07:58:07 +03:00
case c3__both: return u3nc(c3n, c3n);
case c3__free: return u3nc(c3y, c3y);
case c3__read: return u3nc(((met == c3__zinc) ? c3y : c3n), c3n);
case c3__rite: return u3nc(((met == c3__iron) ? c3y : c3n), c3n);
2015-12-27 07:39:38 +03:00
}
}
/* boilerplate
*/
u3_noun
2016-10-28 03:26:40 +03:00
u3wfu_peel(u3_noun cor)
2015-12-27 07:39:38 +03:00
{
2015-12-27 07:58:07 +03:00
u3_noun sut, way, met, van;
2015-12-27 07:39:38 +03:00
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
2015-12-27 07:58:07 +03:00
u3x_sam_3, &met,
2015-12-27 07:39:38 +03:00
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
2016-10-28 03:26:40 +03:00
return _cqfu_peel(van, sut, way, met);
2015-12-27 07:39:38 +03:00
}
}
u3_noun
2016-10-28 03:26:40 +03:00
u3qfu_peel(u3_noun van,
2015-12-27 07:39:38 +03:00
u3_noun sut,
u3_noun way,
2015-12-27 07:58:07 +03:00
u3_noun met)
2015-12-27 07:39:38 +03:00
{
2016-10-28 03:26:40 +03:00
return _cqfu_peel(van, sut, way, met);
2015-12-27 07:39:38 +03:00
}