2 points by almkglor 5738 days ago | link | parent Ah ah ah.... no! The cute thing is that a 'bool presents the "scanner abstraction". Basically, a scanner is anything that overloads the functions 'car, 'cdr, 'scanner, and 'unscan. Thus, you don't have to check for the type of an object: you just need to pass it through 'scanner. If 'scanner throws, it's not a "list". If 'scanner returns a value, you can be sure that it returns a value that will be legitimately passed to 'car and 'cdr.From this point of view, a "list" is anything that happens to be a scanner.So nil is a list. So are 'cons cells. So are anything that overloads 'scanner, 'unscan, 'car, and 'cdr.Try:`````` (using v1) `````` ...then play around with (lazy-scanner a d)Or for a bit of ease of use generate an infinite list of positive integers (after doing the 'using thing):`````` (generate [+ _ 1] 1) `````` Edit: to summarize: a list is not a cons cell. A cons cell is a list. ^^
 1 point by almkglor 5738 days ago | link Well, a "list" is a "scanner". So your "not a scanner" doesn't make sense, at least from the point of view of Arc-F.However if you mean "list" as in sequence of cons cells:`````` (def works-on-cons-cells-and-bools (x) (err "this works only on cons cells and bools!")) (defm works-on-cons-cells-and-bools ((t x cons)) (work-on-cons-cells x)) (defm works-on-cons-cells-and-bools ((t x bool)) (work-on-bool x)) `````` Note that you can even define a unifying "type class" function which ensures that the given data is a cons cell or a bool, or is convertible to one (i.e. an analog to 'scanner). For example, you might want a "hooper" type class:`````` (def hooper (x) (err "Not convertible to a bool or cons cell" x)) (defm hooper ((t x cons)) x) (defm hooper ((t x bool)) x) `````` Then you can convert works-on-cons-cells-and-bools with the type class:`````` (def work-on-hooper (x) (works-on-cons-cells-and-bools (hooper x))) `````` Then, someone can make a type which supports the "hooper" type class by either overloading hooper (and returning a true hooper), or overloading hooper and works-on-cons-cells-and-bools:choice one:`````` (defm hooper ((t x my-type)) (convert-my-type-to-cons x)) `````` choice two:`````` (defm hooper ((t x my-type)) x) (defm works-on-cons-cells-and-bools ((t x my-type)) (work-on-my-type x))``````-----