I want to write a method that returns a random (predefined) face

In ruby I would do,

def random_face
 [ :my-face-01, :my-face-02, :my-face-03 ].sample(1).first

How can I do it in elisp?

  • Check this post that defines a function to pick a random element from a list. Quite simple. – Juancho Feb 5 '18 at 18:16
  • You aren't asking for the equivalent of sample, but rather the equivalent of generating a random index. This is far easier than picking multiple items from a bag. – wasamasa Feb 5 '18 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.