lake/src/bool.c
2011-04-20 20:47:52 -07:00

43 lines
615 B
C

/**
* bool.c
* Lake Scheme
*
* Copyright 2011 Sami Samhuri
* MIT License
*
*/
#include <glib.h>
#include "bool.h"
#include "lake.h"
#include "sym.h"
LakeBool *bool_from_int(int n)
{
return n ? T : F;
}
gboolean bool_val(LakeBool *b)
{
return b->val;
}
char *bool_repr(LakeBool *b)
{
return g_strdup(BOOL_VAL(b) ? "#t" : "#f");
}
LakeStr *bool_to_str(LakeBool *b)
{
return str_from_c(BOOL_VAL(b) ? "#t" : "#f");
}
LakeVal* bool_and(LakeVal *a, LakeVal *b)
{
return IS_TRUTHY(a) && IS_TRUTHY(b) ? b : a;
}
LakeVal* bool_or(LakeVal *a, LakeVal *b)
{
return IS_TRUTHY(a) ? a : b;
}