PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lisp/Plist.cs

http://github.com/toshok/shelisp
C# | 33 lines | 25 code | 6 blank | 2 comment | 2 complexity | 7933464e8af1fb20742878ff48baefe7 MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using Shelisp;
  3. namespace Shelisp {
  4. public class Plist : Object {
  5. [LispBuiltin]
  6. public static Shelisp.Object Fplist_put (L l, Shelisp.Object plist, Shelisp.Object property, Shelisp.Object value)
  7. {
  8. // XXX let's be assholes and not replace anything in the list. just add onto the front like a boss.
  9. return new List (property, new List (value, plist));
  10. }
  11. [LispBuiltin]
  12. public static Shelisp.Object Fplist_get (L l, Shelisp.Object plist, Shelisp.Object property)
  13. {
  14. Shelisp.Object el = plist;
  15. Shelisp.Object val = L.Qnil;
  16. while (!L.NILP (el)) {
  17. if (L.CAR(el).LispEq (property)) {
  18. // the next thing in the list is the value
  19. val = L.CAR(L.CDR(el));
  20. break;
  21. }
  22. el = L.CDR (el);
  23. }
  24. return val;
  25. }
  26. }
  27. }