Trying to select a random value from the list.
(set 'mylist '((0 0) '(0 1) '(0 2)))
(amb mylist)
Result: ((0 0) (0 1) (0 2))
Different combinations of expand, eval, map and apply wont work in my hands. Only working method I have found is the monstercode with eval-string:
(eval-string (append "(amb '" (join (map string mylist) " '") ")"))
But there should be some simple solution, right?
Hi Fritz,
Try this:
> (set 'mylist '((0 0) (0 1) (0 2)))
((0 0) (0 1) (0 2))
> (apply amb mylist)
(0 2)
> (apply amb mylist)
(0 0)
> (apply amb mylist)
(0 2)
> _
Also notice that only one quote is necessary in creating the list. Hope that helps!
m i c h a e l
m i c h a e l beat me to it...
amb doesn't take a list, just a series of expressions, so:
apply amb my-list
is what you want
Oh, thanx!