本文整理汇总了C++中consp函数的典型用法代码示例。如果您正苦于以下问题:C++ consp函数的具体用法?C++ consp怎么用?C++ consp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了consp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cell_write
static void cell_write(SExp s, int b_escape, struct StreamBase* strm) {
// 省略表示系のチェック
if (consp(CDR(s)) && nullp(CDDR(s))) {
SExp t = CAR(s);
const char* str = NULL;
if (eq(t, intern("quote"))) {
str = "'";
} else if (eq(t, intern("quasiquote"))) {
str = "`";
}
if (str != NULL) {
strm_puts(strm, str, 0);
swrite(CADR(s), b_escape, strm);
return;
}
}
{
int first = TRUE;
SExp p;
strm_puts(strm, "(", 0);
for (p = s; consp(p); p = CDR(p)) {
if (!first) strm_puts(strm, " ", 0);
first = FALSE;
swrite(CAR(p), b_escape, strm);
}
if (!nullp(p)) {
strm_puts(strm, " . ", 0);
swrite(p, b_escape, strm);
}
strm_puts(strm, ")", 0);
}
}
开发者ID:cansou,项目名称:minimallisp,代码行数:33,代码来源:sexp.c
示例2: pplist
/* pplist - pretty print a list */
LOCAL void pplist(LVAL expr)
{
int n;
/* if the expression will fit on one line, print it on one */
if ((n = flatsize(expr)) < ppmaxlen) {
xlprint(ppfile,expr,TRUE);
pplevel += n;
}
/* otherwise print it on several lines */
else {
n = ppmargin;
ppputc('(');
if (atomp(car(expr))) {
ppexpr(car(expr));
ppputc(' ');
ppmargin = pplevel;
expr = cdr(expr);
}
else
ppmargin = pplevel;
for (; consp(expr); expr = cdr(expr)) {
pp(car(expr));
if (consp(cdr(expr)))
ppterpri();
}
if (expr != NIL) {
ppputc(' '); ppputc('.'); ppputc(' ');
ppexpr(expr);
}
ppputc(')');
ppmargin = n;
}
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:36,代码来源:xlpp.c
示例3: StMObDeleteItem
/* to reflect the shift in position */
void StMObDeleteItem(LVAL menu, LVAL item)
{
HMENU addr;
int n, i, j, id, flags;
LVAL items;
char *s;
if (StMObAllocated(menu)) {
addr = get_menu_address(menu);
id = get_menu_id(menu);
i = get_item_position(menu, item);
for (j = 0, items = slot_value(menu, s_items);
j < i && consp(items);
j++, items = cdr(items));
n = GetMenuItemCount((HMENU) addr);
for (; i < n; n--) DeleteMenu((HMENU) addr, i, MF_BYPOSITION);
if (consp(items)) items = cdr(items);
for (; consp(items); items = cdr(items), i++) {
item = car(items);
s = get_item_string(item);
if (s[0] == '-') AppendMenu((HMENU) addr, MF_SEPARATOR, 0, NULL);
else {
flags = MF_STRING;
if (slot_value(item, s_mark) != NIL) flags |= MF_CHECKED;
if (slot_value(item, s_enabled) == NIL) flags |= MF_GRAYED;
AppendMenu((HMENU) addr, flags, MAKEITEMINDEX(id, i), s);
}
}
}
}
开发者ID:jhbadger,项目名称:xlispstat,代码行数:31,代码来源:mswmenus.c
示例4: lisp_print
LISPTR lisp_print(LISPTR x, FILE* out)
{
if (consp(x)) {
fputwc('(', out);
while (true) {
lisp_print(car(x), out);
x = cdr(x);
if (!consp(x)) {
if (x != NIL) {
fputws(L" . ", out);
lisp_print(x, out);
}
break;
}
fputwc(' ', out);
}
fputwc(')', out);
} else if (symbolp(x)) {
fputws(string_text(symbol_name(x)), out);
} else if (numberp(x)) {
fwprintf(out, L"%g", number_value(x));
} else if (stringp(x)) {
fputwc('"', out);
fputws(string_text(x), out);
fputwc('"', out);
} else {
fputws(L"*UNKOBJ*", out);
}
return x;
}
开发者ID:spike0xff,项目名称:isACTR,代码行数:30,代码来源:lispreader.cpp
示例5: is_labels
int is_labels(LVAL expr)
{
/* make sure that we have a list whose first element is a
list of the form (time "label") */
if (!consp(expr))
return 0;
if (!consp(car(expr)))
return 0;
if (!(floatp(car(car(expr))) || fixp(car(car(expr)))))
return 0;
if (!consp(cdr(car(expr))))
return 0;
if (!(stringp(car(cdr(car(expr))))))
return 0;
/* If this is the end of the list, we're done */
if (cdr(expr) == NULL)
return 1;
/* Otherwise recurse */
return is_labels(cdr(expr));
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:29,代码来源:nyx.c
示例6: xnconc
/* xnconc - destructively append lists */
LVAL xnconc(void)
{
LVAL next,last=NULL,val;
/* initialize */
val = NIL;
/* concatenate each argument */
if (moreargs()) {
while (xlargc > 1) {
/* ignore everything except lists */
if ((next = nextarg()) && consp(next)) {
/* concatenate this list to the result list */
if (val) rplacd(last,next);
else val = next;
/* find the end of the list */
while (consp(cdr(next)))
next = cdr(next);
last = next;
}
}
/* handle the last argument */
if (val) rplacd(last,nextarg());
else val = nextarg();
}
/* return the list */
return (val);
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:34,代码来源:xllist.c
示例7: xassoc
/* xassoc - built-in function 'assoc' */
LVAL xassoc(void)
{
LVAL x,alist,fcn,pair,val;
int tresult;
/* protect some pointers */
xlsave1(fcn);
/* get the expression to look for and the association list */
x = xlgetarg();
alist = xlgalist();
xltest(&fcn,&tresult);
/* look for the expression */
for (val = NIL; consp(alist); alist = cdr(alist))
if ((pair = car(alist)) && consp(pair))
if (dotest2(x,car(pair),fcn) == tresult) {
val = pair;
break;
}
/* restore the stack */
xlpop();
/* return result */
return (val);
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:28,代码来源:xllist.c
示例8: get_acceptable_type
static sexpr get_acceptable_type (sexpr lq)
{
sexpr types = get_acceptable_types (lq), ta,
mape = lx_environment_alist (mime_map), n;
while (consp (types))
{
ta = car (types);
n = mape;
while (consp (n))
{
if (truep (equalp (ta, cdr (car (n)))))
{
return ta;
}
n = cdr (n);
}
types = cdr (types);
}
return default_type;
}
开发者ID:kyuba,项目名称:khonsu,代码行数:25,代码来源:backend.c
示例9: bind_args
LISPTR bind_args(LISPTR formals, LISPTR acts, LISPTR prev)
{
if (!consp(formals)) {
return prev;
}
return cons(cons(car(formals), consp(acts) ? eval(car(acts)) : NIL), bind_args(cdr(formals), consp(acts) ? cdr(acts) : NIL, prev));
}
开发者ID:spike0xff,项目名称:isACTR,代码行数:7,代码来源:lispeval.cpp
示例10: xlfail
/* xlapply - apply a function to a list of arguments */
NODE *xlapply(NODE *fun,NODE *args)
{
NODE *env,*val;
val = 0; //BUG: uninitialized variable is used if xlfail returns
/* check for a null function */
if (fun == NIL)
xlfail("bad function");
/* evaluate the function */
if (subrp(fun))
val = (*getsubr(fun))(args);
else if (consp(fun)) {
if (consp(car(fun))) {
env = cdr(fun);
fun = car(fun);
}
else
env = xlenv;
if (car(fun) != s_lambda)
xlfail("bad function type");
val = evfun(fun,args,env);
}
else
xlfail("bad function");
/* return the result value */
return (val);
}
开发者ID:8l,项目名称:csolve,代码行数:30,代码来源:xleval.c
示例11: xcar
bool Array_T::typep(Value type) const
{
if (consp(type))
{
Value type_specifier_atom = xcar(type);
Value tail = xcdr(type);
if (type_specifier_atom == S_array)
{
if (consp(tail))
{
Value element_type = xcar(tail);
tail = xcdr(tail);
if (element_type == UNSPECIFIED || ::equal(element_type, _element_type)
|| (_element_type == S_bit && ::equal(element_type, BIT_TYPE)))
{
if (tail == NIL)
return true;
if (::length(tail) == 1)
{
Value dimensions = xcar(tail);
if (dimensions == UNSPECIFIED)
return true;
if (dimensions == make_fixnum(_rank))
return true;
if (consp(dimensions))
{
if (::length(dimensions) == _rank)
{
unsigned long i = 0;
while (dimensions != NIL)
{
Value dim = xcar(dimensions);
if (dim == UNSPECIFIED || dim == make_fixnum(_dimensions[i]))
; // ok
else
return false;
dimensions = xcdr(dimensions);
++i;
}
return true;
}
}
}
}
}
}
}
else if (symbolp(type))
{
if (type == S_array || type == S_atom || type == T)
return true;
}
else
{
if (type == C_array || type == C_t)
return true;
}
return false;
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:59,代码来源:Array_T.cpp
示例12: return
/* findprop - find a property pair */
LOCAL NODE *findprop(NODE *sym,NODE *prp)
{
NODE *p;
for (p = getplist(sym); consp(p) && consp(cdr(p)); p = cdr(cdr(p)))
if (car(p) == prp)
return (cdr(p));
return (NIL);
}
开发者ID:8l,项目名称:csolve,代码行数:9,代码来源:xlsym.c
示例13: findprop
/* findprop - find a property pair */
LVAL findprop(LVAL sym, LVAL prp)
{
LVAL p;
for (p = getplist(sym); consp(p) && consp(cdr(p)); p = cdr(cdr(p)))
if (car(p) == prp)
return (cdr(p));
return (NIL);
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:9,代码来源:xlsym.c
示例14: xcar
bool SimpleArray_UB16_1::typep(Value type) const
{
if (consp(type))
{
Value type_specifier_atom = xcar(type);
Value tail = xcdr(type);
if (type_specifier_atom == S_array || type_specifier_atom == S_simple_array)
{
if (consp(tail))
{
Value element_type = xcar(tail);
if (element_type == UNSPECIFIED)
; // ok
else
{
Value upgraded_element_type = upgraded_array_element_type(element_type);
if (::equal(upgraded_element_type, UB16_TYPE))
; // ok
else if (::equal(upgraded_element_type,
list3(S_integer, FIXNUM_ZERO, make_fixnum(65535))))
; // ok
else if (::equal(upgraded_element_type,
list3(S_integer, FIXNUM_ZERO, list1(make_fixnum(65536)))))
; // ok
else
return false;
}
tail = xcdr(tail);
if (tail == NIL)
return true;
if (cdr(tail) == NIL) // i.e. length(tail) == 1
{
Value dimensions = xcar(tail);
if (dimensions == UNSPECIFIED)
return true;
if (dimensions == FIXNUM_ONE)
return true;
if (::equal(dimensions, list1(UNSPECIFIED)))
return true;
if (::equal(dimensions, list1(make_fixnum(_capacity))))
return true;
}
}
}
}
else if (symbolp(type))
{
if (type == S_vector || type == S_sequence || type == S_simple_array
|| type == S_array || type == S_atom || type == T)
return true;
}
else
{
if (type == C_vector || type == C_array || type == C_sequence || type == C_t)
return true;
}
return false;
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:58,代码来源:SimpleArray_UB16_1.cpp
示例15: test_one_env
LOCAL void test_one_env(LVAL environment, int i, char *s)
{
register LVAL fp,ep;
LVAL val;
/* check the environment list */
for (fp = environment; fp; fp = cdr(fp)) {
/* check that xlenv is good */
if (!consp(fp)) {
sprintf(buf,"%s: xlenv 0x%lx, frame 0x%lx, type(frame) %d\n",
s, xlenv, fp, ntype(fp));
errputstr(buf);
report_exit("xlenv points to a bad list", i);
}
/* check for an instance variable */
if ((ep = car(fp)) && objectp(car(ep))) {
/* do nothing */
}
/* check an environment stack frame */
else {
for (; ep; ep = cdr(ep)) {
/* check that ep is good */
if (!consp(ep)) {
sprintf(buf,"%s: fp 0x%lx, ep 0x%lx, type(ep) %d\n",
s, fp, ep, ntype(ep));
errputstr(buf);
report_exit("car(fp) points to a bad list", i);
}
/* check that car(ep) is nonnull */
if (!car(ep)) {
sprintf(buf,"%s: ep 0x%lx, car(ep) 0x%lx\n",
s, ep, car(ep));
errputstr(buf);
report_exit("car(ep) (an association) is NULL", i);
}
/* check that car(ep) is a cons */
if (!consp(car(ep))) {
sprintf(buf,"%s: ep 0x%lx, car(ep) 0x%lx, type(car(ep)) %d\n",
s, ep, car(ep), ntype(car(ep)));
errputstr(buf);
report_exit("car(ep) (an association) is not a cons", i);
}
/* check that car(car(ep)) is a symbol */
if (!symbolp(car(car(ep)))) {
sprintf(buf,"%s: ep 0x%lx, car(ep) 0x%lx, car(car(ep)) 0x%lx, type(car(car(ep))) %d\n",
s, ep, car(ep), car(car(ep)), ntype(car(car(ep))));
errputstr(buf);
report_exit("car(car(ep)) is not a symbol", i);
}
}
}
}
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:57,代码来源:xlsym.c
示例16: return
bool SimpleString::typep(Value type) const
{
if (classp(type))
return (type == C_string || type == C_vector || type == C_array
|| type == C_sequence || type == C_t);
if (symbolp(type))
return (type == S_string || type == S_base_string || type == S_simple_string
|| type == S_simple_base_string || type == S_vector
|| type == S_simple_array || type == S_array || type == S_sequence
|| type == S_atom || type == T);
if (consp(type))
{
Value type_specifier_atom = xcar(type);
Value tail = xcdr(type);
if (type_specifier_atom == S_array || type_specifier_atom == S_simple_array)
{
if (consp(tail))
{
Value element_type = xcar(tail);
tail = xcdr(tail);
if (element_type == UNSPECIFIED || element_type == S_character
|| element_type == S_base_char)
{
if (tail == NIL)
return true;
if (cdr(tail) == NIL) // i.e. length(tail) == 1
{
Value dimensions = xcar(tail);
if (dimensions == UNSPECIFIED)
return true;
if (dimensions == FIXNUM_ONE)
return true;
if (consp(dimensions))
{
if (::length(dimensions) == 1)
{
Value dim = xcar(dimensions);
if (dim == UNSPECIFIED || dim == make_fixnum(_capacity))
return true;
}
}
}
}
}
}
else if (type_specifier_atom == S_string
|| type_specifier_atom == S_base_string
|| type_specifier_atom == S_simple_string
|| type_specifier_atom == S_simple_base_string)
{
Value size = car(tail);
return (size == UNSPECIFIED || check_index(size) == _capacity);
}
}
return false;
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:56,代码来源:SimpleString.cpp
示例17: sexpr_to_graph
static sexpr sexpr_to_graph (sexpr sx)
{
sexpr g = graph_create ();
sexpr c = car(sx);
while (consp(c))
{
sexpr cx = car (c);
sexpr cxcar = car (cx);
graph_add_node (g, cxcar);
c = cdr (c);
}
c = cdr(sx);
while (consp(c))
{
sexpr cx = car (c);
sexpr cxcar = car (cx);
sexpr cxcdr = cdr (cx);
sexpr cxcadr = car (cxcdr);
sexpr cxcddr = cdr (cxcdr);
struct graph_node *ns = graph_search_node (g, cxcar);
struct graph_node *nt = graph_search_node (g, cxcadr);
if ((ns != (struct graph_node *)0) && (nt != (struct graph_node *)0))
{
graph_node_add_edge (ns, nt, cxcddr);
}
c = cdr (c);
}
c = car(sx);
while (consp(c))
{
sexpr cx = car (c);
sexpr cxcar = car (cx);
sexpr cxcdr = cdr (cx);
struct graph_node *n = graph_search_node (g, cxcar);
if (n != (struct graph_node *)0)
{
n->label = cxcdr;
}
c = cdr (c);
}
return g;
}
开发者ID:fywtat,项目名称:curie,代码行数:56,代码来源:graph.c
示例18: nyx_is_labels
LOCAL int nyx_is_labels(LVAL expr)
{
/* make sure that we have a list whose first element is a
list of the form (time "label") */
LVAL label;
LVAL first;
LVAL second;
LVAL third;
if (expr == NULL) {
return 0;
}
while (expr != NULL) {
if (!consp(expr)) {
return 0;
}
label = car(expr);
if (!consp(label)) {
return 0;
}
first = car(label);
if (!(floatp(first) || fixp(first))) {
return 0;
}
if (!consp(cdr(label))) {
return 0;
}
second = car(cdr(label));
if (floatp(second) || fixp(second)) {
if (!consp(cdr(cdr(label)))) {
return 0;
}
third = car(cdr(cdr(label)));
if (!(stringp(third))) {
return 0;
}
}
else {
if (!(stringp(second))) {
return 0;
}
}
expr = cdr(expr);
}
return 1;
}
开发者ID:tuanmasterit,项目名称:audacity,代码行数:56,代码来源:nyx.c
示例19: assoc
/* assoc - find a pair in an association list */
LOCAL LVAL assoc(LVAL expr, LVAL alist, LVAL fcn, int tresult)
{
LVAL pair;
for (; consp(alist); alist = cdr(alist))
if ((pair = car(alist)) && consp(pair))
if (dotest2(expr,car(pair),fcn) == tresult)
return (pair);
return (NIL);
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:11,代码来源:xllist.c
示例20: sx_set_difference
static void handle_external_mod_update
(struct kyu_module *newdef, struct kyu_module *mydef)
{
sexpr c, a, module, rv = sx_nil, flags = newdef->schedulerflags;
c = sx_set_difference (mydef->schedulerflags, newdef->schedulerflags);
if (eolp (c))
{
return;
}
while (consp (c) && nilp (rv))
{
a = car (c);
if (truep (equalp (a, sym_enabling)))
{
if (falsep (sx_set_memberp (mydef->schedulerflags, sym_enabling)))
{
rv = handle_enable_request (mydef);
if (falsep (rv))
{
flags = sx_set_add (mydef->schedulerflags, sym_blocked);
}
}
}
else if (truep (equalp (a, sym_disabling)))
{
if (falsep (sx_set_memberp (mydef->schedulerflags, sym_disabling)))
{
rv = handle_disable_request (mydef);
}
}
else if (consp (a) &&
falsep (sx_set_memberp (mydef->schedulerflags, a)))
{
rv = handle_action (mydef, cdr (a));
}
c = cdr (c);
}
module = kyu_make_module
(mydef->name, mydef->description, mydef->provides,
mydef->requires, mydef->before, mydef->after, mydef->conflicts,
flags, mydef->functions);
my_modules = lx_environment_unbind (my_modules, mydef->name);
my_modules = lx_environment_bind (my_modules, mydef->name, module);
kyu_command (cons (sym_update, cons (native_system,
cons (module, sx_end_of_list))));
}
开发者ID:kyuba,项目名称:core,代码行数:55,代码来源:server-seteh.c
注:本文中的consp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论