Commit 117f608c authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

identity, ignore, list -> Lisp; Bre_subst new

parent 3fb37649
......@@ -289,10 +289,6 @@ sub Bsplit_string {
return array2list(@result);
}
sub Bignore {
return $Nil;
}
sub Bsymbol_plist {
my ($sym) = checkargs($_[0], 'y');
return symbol_plist($sym);
......@@ -404,6 +400,19 @@ sub Bre_match {
return array2list(@result);
}
sub Bre_subst {
my ($regexp, $subst, $string, $options) = checkargs($_[0], 'SSS:S');
$_ = $string;
$options = '' if is_nil($options);
my $code = "s{$regexp}{$subst}$options";
#warn("re-subst: >>$code<<");
eval($code);
if ($@) {
error("re-subst: $@");
}
return $_;
}
sub Bconcat {
my ($arglist) = @_;
my $result = "";
......@@ -680,11 +689,6 @@ sub Bdefun {
return $name;
}
sub Blist {
my ($arglist) = @_;
return $arglist;
}
sub Bcar {
my ($list) = checkargs($_[0], 'l');
return car($list);
......@@ -1094,7 +1098,7 @@ my @builtins = # [name, func, is_special, doc]
["errset", \&Berrset, 1,
"return value of EXPR as singleton list, or nil in case of error"],
["eval", \&Beval, 0,
"evaluate Lisp EXPRESSION"],
"evaluate EXPRESSION"],
["exit", \&Bexit, 0,
"exit Lis.pl with STATUS"],
["fboundp", \&Bfboundp, 0,
......@@ -1117,12 +1121,8 @@ my @builtins = # [name, func, is_special, doc]
"from OBJECT's plist, get value of property INDICATOR"],
["glob-filenames", \&Bglob_filenames, 0,
"return the list of file names matching PATTERN"],
["identity", \&Bquote, 0,
"return the argument"],
["if", \&Bif, 1,
"if COND is true, evaluate THEN-CLAUSE, otherwise all other clauses"],
["ignore", \&Bignore, 0,
"ignore all arguments and return nil"],
["incf", \&Bincf, 1,
"increment number VAR by DELTA (or 1) and return the new value"],
["intern", \&Bintern, 0,
......@@ -1135,14 +1135,10 @@ my @builtins = # [name, func, is_special, doc]
"evaluate body with local bindings: (let ((var value) ...) body)"],
["let*", \&Blet_star, 1,
"evaluate body with local bindings: (let* ((var value) ...) body)"],
["list", \&Blist, 0,
"return a new list from the arguments"],
["listp", \&Blistp, 0,
"return t if OBJECT is a list, 0, otherwise nil"],
["load", \&Bload, 0,
"load FILE, optional args NOERROR, NOMESSAGE"],
["load", \&Bload, 0,
"load expressions from specified file"],
["makunbound", \&Bmakunbound, 0,
"make SYMBOL's value be undefined"],
["null", \&Bnull, 0,
......@@ -1173,6 +1169,8 @@ my @builtins = # [name, func, is_special, doc]
"return a random number a with 0 <= a < LIMIT (or 1)"],
["re-match", \&Bre_match, 0,
"match REGEXP to a string and return the result(s)"],
["re-subst", \&Bre_subst, 0,
"match REGEXP to a string, substitute by SUBST, and return the result"],
["read", \&Bread, 0,
"return an expression read from stdin or &optional INPUT (a string)"],
["remprop", \&Bremprop, 0,
......
......@@ -545,6 +545,18 @@ list as appropriate."
(+ (fib (- n 1))
(fib (- n 2)))))
(defun identity (ob)
"return the argument"
ob)
(defun ignore (&rest args)
"ignore all arguments and return nil"
nil)
(defun list (&rest args)
"return a new list from the arguments"
args)
(defun assoc (item alist)
"return the pair of ALIST whose car is equal to ITEM, or nil"
(if (null alist)
......
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