当前位置: 首页>>代码示例>>C++>>正文


C++ consp函数代码示例

本文整理汇总了C++中consp函数的典型用法代码示例。如果您正苦于以下问题:C++ consp函数的具体用法?C++ consp怎么用?C++ consp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了consp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的consp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。