mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
- 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
43 lines
615 B
C
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;
|
|
}
|