Skip to content

Commit f24da3e

Browse files
committed
Add: string<?, mvadic append
1 parent c25301b commit f24da3e

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"src/storage.c",
3636
"src/strbldr.c",
3737
//
38-
"-O2", // Optimization Level. Tail Call Optimization seem to need >= 2
38+
"-O3", // Optimization Level. Tail Call Optimization seem to need >= 2
3939
"-std=c17", // 'ISO C 2017' standard
4040
"-o",
4141
"${workspaceFolder}/bin/sicp", // output e.g., "${fileDirname}/sicp",

src/custom.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ static obj add_extras(int ex, obj env)
380380
of_function(string_to_symbol_p), env);
381381
define_variable(of_identifier("symbol->string"),
382382
of_function(symbol_to_string_p), env);
383+
define_variable(of_identifier("string<?"),
384+
of_function(string_lt_p), env);
383385
}
384386

385387
return unspecified;

src/list.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,14 @@ obj append(obj lst1, obj lst2)
149149

150150
obj append_p(obj args)
151151
{
152-
obj chk = chkarity("append", 2, args);
153-
if (is_err(chk))
154-
return chk;
155-
return append(car(chk), cadr(chk));
152+
// obj chk = chkarity("append", 2, args);
153+
// if (is_err(chk))
154+
// return chk;
155+
obj lst = emptylst;
156+
for (; is_pair(args); args = cdr(args)) {
157+
lst = append(car(args), lst);
158+
}
159+
return lst;
156160
}
157161

158162
// ACCESSORS - internal

src/primproc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,17 @@ obj symbol_to_string_p(obj args)
800800
return r;
801801
}
802802

803+
obj string_lt_p(obj args)
804+
{
805+
obj chk;
806+
807+
if (is_err(chk = chkarity("string<?", 2, args)))
808+
return chk;
809+
return strcmp(to_string(car(args)), to_string(cadr(args))) < 0 ?
810+
true_o :
811+
false_o;
812+
}
813+
803814
obj pcnt_ex(obj args)
804815
{
805816
(void)args;

src/primproc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ obj number_to_string_p(obj);
6262
obj string_to_symbol_p(obj);
6363
obj symbol_to_string_p(obj);
6464

65+
obj string_lt_p(obj);
66+
6567
obj pcnt_ex(obj);
6668

6769
#endif

0 commit comments

Comments
 (0)