Fix Makefile stats/stats-lisp.
if nargin < 3
last = length(obj.data);
end
- ret = types.List(obj.data{start:end});
+ ret = types.List(obj.data{start:last});
end
function ret = clone(obj)
ret = fenv.data(k.name);
else
throw(MException('ENV:notfound', ...
- strcat('''', k.name, ''' not found')));
+ sprintf('''%s'' not found', k.name)));
end
end
end
-SOURCES_BASE = Reader.m types/Symbol.m reader.m printer.m
-#SOURCES_LISP = env.m core.m stepA_interop.m
-SOURCES_LISP = stepA_interop.m
+SOURCES_BASE = types.m types/Nil.m types/MalException.m \
+ types/Symbol.m types/List.m types/Vector.m \
+ types/HashMap.m types/Function.m types/Atom.m \
+ Reader.m reader.m printer.m
+SOURCES_LISP = Env.m core.m stepA_interop.m
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
n('count') = @(a) length(a);
n('apply') = @core.apply;
n('map') = @core.map;
+ n('conj') = @(x) disp('not implemented yet');
n('with-meta') = @core.with_meta;
n('meta') = @core.meta;
str = num2str(obj);
case 'char'
if types.keyword_Q(obj)
- str = strcat(':', obj(2:end));
+ str = sprintf(':%s', obj(2:end));
else
if print_readably
str = strrep(obj, '\', '\\');
str = strrep(str, '"', '\"');
str = strrep(str, char(10), '\n');
- str = strcat('"', str, '"');
+ str = sprintf('"%s"', str);
else
str = obj;
end
case 'types.List'
strs = cellfun(@(x) printer.pr_str(x, print_readably), ...
obj.data, 'UniformOutput', false);
- str = strcat('(', strjoin(strs, ' '), ')');
+ str = sprintf('(%s)', strjoin(strs, ' '));
case 'types.Vector'
strs = cellfun(@(x) printer.pr_str(x, print_readably), ...
obj.data, 'UniformOutput', false);
- str = strcat('[', strjoin(strs, ' '), ']');
+ str = sprintf('[%s]', strjoin(strs, ' '));
case 'types.HashMap'
strs = {};
ks = obj.keys();
strs{end+1} = printer.pr_str(k, print_readably);
strs{end+1} = printer.pr_str(obj.get(k), print_readably);
end
- str = strcat('{', strjoin(strs, ' '), '}');
+ str = sprintf('{%s}', strjoin(strs, ' '));
case 'types.Nil'
str = 'nil';
case 'logical'
seq = {};
token = rdr.next();
if not(strcmp(token, start))
- error(strcat('expected ''', start, ''''));
+ error(sprintf('expected ''%s''', start));
end
token = rdr.peek();
while true
if eq(token, false)
- error(strcat('expected ''', last, ''''));
+ error(sprintf('expected ''%s''', last));
end
if strcmp(token, last), break, end
seq{end+1} = reader.read_form(rdr);
end
function ret = EVAL(ast, env)
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
end
function ret = EVAL(ast, env)
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
end
function ret = EVAL(ast, env)
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env);
if ~isempty(args)
- rep(strcat('(load-file "', args{1}, '")'), repl_env);
+ rep(sprintf('(load-file "%s")', args{1}), repl_env);
quit;
end
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
rep('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))"', repl_env);
if ~isempty(args)
- rep(strcat('(load-file "', args{1}, '")'), repl_env);
+ rep(sprintf('(load-file "%s")', args{1}), repl_env);
quit;
end
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
rep('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))', repl_env);
if ~isempty(args)
- rep(strcat('(load-file "', args{1}, '")'), repl_env);
+ rep(sprintf('(load-file "%s")', args{1}), repl_env);
quit;
end
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
rep('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))', repl_env);
if ~isempty(args)
- rep(strcat('(load-file "', args{1}, '")'), repl_env);
+ rep(sprintf('(load-file "%s")', args{1}), repl_env);
quit;
end
function ret = EVAL(ast, env)
while true
+ %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
if ~types.list_Q(ast)
ret = eval_ast(ast, env);
return;
rep('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))', repl_env);
if ~isempty(args)
- rep(strcat('(load-file "', args{1}, '")'), repl_env);
+ rep(sprintf('(load-file "%s")', args{1}), repl_env);
quit;
end
end
function ret = keyword(str)
- ret = strcat(native2unicode(hex2dec('029e'),'UTF-8'), ...
- str(2:end));
+ ret = sprintf('%s%s', native2unicode(hex2dec('029e'),'UTF-8'), ...
+ str(2:end));
end
function ret = keyword_Q(obj)
ret = length(obj) > 1 && ...