Dear group,
I have a list of symbols which may look like this:
(define list1 '(pref_1 justsomething pref_2 interface_1 pref_3
interface_2 pre_1))
(define list2 '(pref_1 something pref_2 interface_1 pref_3 interface_2
pre_1 we you))
I have to sort them into differnet lists depending on their prefixes:
symbols starting with "pre_" go in one list, starting with "pref_" in
another, on more for "interface_" and another one for all the other
symbols... I tried the following code:
(define pref '())
(define pre '())
(define interface '())
(define other '())
(for-each
(lambda loop
(cond
((string-ci=? (substring (symbol->string (car loop)) 0 4 )
"pre_") (set! pre (cons (car loop) pre)))
((string-ci=? (substring (symbol->string (car loop)) 0 5 )
"pref_") (set! pref (cons (car loop) pref)))
((string-ci=? (substring (symbol->string (car loop)) 0 10 )
"interface_") (set! interface (cons (car loop) interface)))
(else (set! other (cons (car loop) other)))))
list1)
(display list1)(newline)
(display pre)(newline)
(display pref)(newline)
(display interface)(newline)
(display other)(newline)
This obviously works for list1 but not for list2. I tried to add an
additional "if" statement, however this fails the "else" to work. How
could this be done? Thanks.
BastiL