lake/bool.c
Sami Samhuri 54831a34fa added eval and apply, lambdas, other goodies
- add booleans, dotted lists, functions
- proper lexical scope
- special forms: define, set!, and, or, quote, lambda
- added some basic list manipulations
- print functions and dotted lists
- removed nil
- more robust in general
2011-04-20 01:38:53 -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;
}