00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2006--2007 Petter Urkedal <urkedal@nbi.dk> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CUEX_TUPLE_H 00019 #define CUEX_TUPLE_H 00020 00021 #include <cuex/fwd.h> 00022 #include <cuex/oprdefs.h> 00023 00024 CU_BEGIN_DECLARATIONS 00025 /*!\defgroup cuex_tuple_h cuex/tuple.h: Support Functions for Variable Length Tuples 00026 * @{\ingroup cuex_mod 00027 * These are helper functions for expressions of \ref CUEX_OR_TUPLE. It's 00028 * safe to process the operations directly, and things that are easy to do 00029 * with the generic expression functionality is intentionally left out. 00030 */ 00031 00032 CU_SINLINE cu_bool_t cuex_opr_is_tuple(cuex_meta_t opr) 00033 { return cuex_opr_sans_arity(opr) == CUEX_OR_TUPLE(0); } 00034 00035 /*!True iff \a e is a variable-length tuple. */ 00036 CU_SINLINE cu_bool_t cuex_is_tuple(cuex_t e) 00037 { return cuex_opr_sans_arity(cuex_meta(e)) == CUEX_OR_TUPLE(0); } 00038 00039 /*!The arity of \a e. Same as the operator arity. */ 00040 CU_SINLINE cu_rank_t cuex_tuple_r(cuex_t e) 00041 { return cuex_opr_r(cuex_meta(e)); } 00042 00043 /*!Returns the sub-tuple from position \a begin inclusive to position \a end 00044 * exclusive. */ 00045 cuex_t cuex_tuple_sub(cuex_t tuple, cu_rank_t begin, cu_rank_t end); 00046 00047 /*!A variant of \ref cuex_tuple_sub which prepends \a carg to the result 00048 * tuple. The size of the tuple will be \a end - \a begin. */ 00049 cuex_t cuex_tuple_sub_carg(cuex_t carg, cuex_t tuple, 00050 cu_rank_t begin, cu_rank_t end); 00051 00052 /*!Returns the tuple formed by appending \a tuple0 and \a tuple1. */ 00053 cuex_t cuex_tuple_append(cuex_t tuple0, cuex_t tuple1); 00054 00055 /*!@}*/ 00056 CU_END_DECLARATIONS 00057 00058 #endif