Commit 045292f6 authored by Chris Müller's avatar Chris Müller
Browse files

Add primitive for tuples

parent d400fc14
......@@ -123,9 +123,14 @@ struct value* string(const byte_t* string_value);
struct value* character(unicode_t char_value);
struct value* primitive(primitive_t fun_value);
struct value* port(FILE* stream);
struct value* procedure(struct value* env, struct value* param, struct value* body);
struct value* value_dup(struct value* value);
#define NTH(obj, index) (obj->tuple.data[index])
struct value* tuple_new(size_t size);
struct value* tuple2(struct value* v1, struct value* v2);
#define HEAD(obj) (obj->pair.head)
#define TAIL(obj) (obj->pair.tail)
......@@ -139,9 +144,6 @@ size_t list_length(struct value* value);
struct value* list_to_tuple(struct value* value);
struct value* list_reverse(struct value* value);
struct value* tuple_new(size_t size);
struct value* procedure(struct value* env, struct value* param, struct value* body);
// ----------------------------------------------------------------------------
// Symboltables and Environment
......
......@@ -353,6 +353,17 @@ tuple_new(size_t size)
return tuple;
}
struct value*
tuple2(struct value* v1, struct value* v2)
{
struct value* tuple = tuple_new(2);
TUPLE_DATA(tuple)[0] = v1;
TUPLE_DATA(tuple)[1] = v2;
return tuple;
}
// ----------------------------------------------------------------------------
// Print
// ----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment