public
Description: The Nu programming language.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nu.git
Added helper function for creating lists from C.
timburks (author)
Tue Apr 01 17:15:35 -0700 2008
commit  51375eee53ff479f25acb5ed33c411277aef989d
tree    667a20cb68d2f43b2809d791c10c4a75b8db540f
parent  81af97297a14addea47dee1e5d19d76b1ed45a58
...
81
82
83
 
...
81
82
83
84
0
@@ -81,3 +81,4 @@ id _nusymbol(const char *string);
0
 id _nunumberd(double d);
0
 id _nucell(id car, id cdr);
0
 id _nuregex(const char *pattern, int options);
0
+id _nulist(id firstObject,...);
...
316
317
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
320
321
...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
0
@@ -316,6 +316,31 @@ id _nuregex(const char *pattern, int options)
0
     return [NuRegex regexWithPattern:_nustring(pattern) options:options];
0
 }
0
 
0
+id _nulist(id firstObject, ...)
0
+{
0
+ id list = nil;
0
+ id eachObject;
0
+ va_list argumentList;
0
+ if (firstObject) {
0
+ // The first argument isn't part of the varargs list,
0
+ // so we'll handle it separately.
0
+ list = [[[NuCell alloc] init] autorelease];
0
+ [list setCar:firstObject];
0
+ id cursor = list;
0
+ va_start(argumentList, firstObject);
0
+ // Start scanning for arguments after firstObject.
0
+ // As many times as we can get an argument of type "id"
0
+ // that isn't nil, add it to self's contents.
0
+ while ((eachObject = va_arg(argumentList, id))) {
0
+ [cursor setCdr:[[[NuCell alloc] init] autorelease]];
0
+ cursor = [cursor cdr];
0
+ [cursor setCar:eachObject];
0
+ }
0
+ va_end(argumentList);
0
+ }
0
+ return list;
0
+}
0
+
0
 @implementation Nu
0
 + (id<NuParsing>) parser
0
 {

Comments

    No one has commented yet.