urbit/gen164/6/ut_fink.c

79 lines
1.8 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/fink.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* logic
*/
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
_cqfu_fink(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
u2_noun dep,
u2_noun way,
u2_noun cog)
2013-09-29 00:21:18 +04:00
{
2014-09-03 07:36:29 +04:00
// u2_noun dun = u2_cqfu_dunq(van, "type", sut);
u2_noun nuc = (u2_blip == cog)
2014-09-03 07:36:29 +04:00
? u2_cqfu_shew
2014-08-21 01:18:34 +04:00
(van,
u2nc
(u2nc('c', u2_ci_string("find-limb")),
2013-09-29 00:21:18 +04:00
'$'))
2014-09-03 07:36:29 +04:00
: u2_cqfu_shep
2014-08-21 01:18:34 +04:00
(van, "find-limb", 'a', u2k(cog));
2013-09-29 00:21:18 +04:00
u2_noun pro;
2014-08-21 01:18:34 +04:00
// u2_ct_push(u2nc(c3__mean, dun));
u2_ct_push(u2nc(c3__mean, nuc));
2013-09-29 00:21:18 +04:00
{
2014-09-03 07:36:29 +04:00
u2_noun hoq = u2_cqfu_find(van, sut, dep, way, cog);
2014-08-21 01:18:34 +04:00
u2_noun fin = u2t(hoq);
2013-09-29 00:21:18 +04:00
if ( u2_nul == fin ) {
2014-08-21 01:18:34 +04:00
return u2_cm_error("find-none");
2013-09-29 00:21:18 +04:00
}
else {
2014-08-21 01:18:34 +04:00
pro = u2k(u2t(fin));
u2z(hoq);
2013-09-29 00:21:18 +04:00
}
}
2014-08-21 01:18:34 +04:00
u2_ct_drop();
// u2_ct_drop();
2013-09-29 00:21:18 +04:00
return pro;
}
/* boilerplate
*/
2014-09-04 01:33:18 +04:00
u2_noun
u2_cwfu_fink(u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun sut, dep, way, cog, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &dep,
u2_cv_sam_6, &way,
u2_cv_sam_7, &cog,
u2_cv_con, &van,
2013-09-29 00:21:18 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 09:46:55 +04:00
return _cqfu_fink(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
}
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 07:36:29 +04:00
u2_cqfu_fink(
2014-09-04 01:33:18 +04:00
u2_noun van,
u2_noun sut,
2013-09-29 00:21:18 +04:00
u2_noun dep,
2014-09-04 01:33:18 +04:00
u2_noun way,
u2_noun cog)
2013-09-29 00:21:18 +04:00
{
2014-09-03 09:46:55 +04:00
return _cqfu_fink(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
}