Login
7 branches 0 tags
Ben (X13/Arch) Added support for marking widgets 9a24fa2 4 years ago 175 Commits
nujel / lib / operation / list.c
/*
 * Wolkenwelten - Copyright (C) 2020-2021 - Benjamin Vincent Schulenburg
 *
 * This project uses the MIT license, a copy should be included under /LICENSE
 */
#include "list.h"
#include "../nujel.h"
#include "../collection/list.h"
#include "../type/native-function.h"
#include "../type/val.h"

static lVal *lnfCar(lClosure *c, lVal *v){
	(void)c;
	return lCaar(v);
}

static lVal *lnfCdr(lClosure *c, lVal *v){
	(void)c;
	return lCdar(v);
}

static lVal *lnfCons(lClosure *c, lVal *v){
	(void)c;
	return lCons(lCar(v),lCadr(v));
}

void lOperationsList(lClosure *c){
	lAddNativeFunc(c,"car",     "[list]",     "Returs the head of LIST",          lnfCar);
	lAddNativeFunc(c,"cdr",     "[list]",     "Return the rest of LIST",          lnfCdr);
	lAddNativeFunc(c,"cons",    "[car cdr]",  "Return a new pair of CAR and CDR", lnfCons);
}