It appears the shifted-p function that Grrr1337 posted meets that criteria.
Well now this problem is 'sorted-out', everyone could post their further attempts.
Theres might be another question for dealing with nested lists(which would involve recursion):
(foo '((1 2 3)((3 2 1)) 2) '((3 1 2) 2 (1 3 2)) )
1. What is the advantage of using lambda but naming it with setq? Is this the same as using defun and localizing the symbol? just a cleaner way?
lambda's purpose is to define an annonymous function on-the-fly. That said you have two options:
- Provide arguments and evaluate it instantly
- Make it named function and evaluate it later
So in that example its the same as
defun, but I'm used to define like that functions on-the-fly, that are going to be used only inside the main code (aswell localising them in there).
Same can be done with
defun ofcourse, I'm just writing under my own(made-up) rules.
2. Why us vl-prin1-to-string here? I guess it's a way to convert all elements to the same data type and sort them? but how are strings sorted? by ascii values?
Yes, since Lee pointed out the
vl-sort issue (that it removes duplicate elements after sorting - more specifically: numbers),
vl-prin1-to-string is required to just print them as strings and the
vl-sort then sorts by ascii values.
ofcourse
acad_strlsort is also an option.