[18]> (position 3 '(1 2 3 4 5 6 7 8) :from-end nil) 2 [19]> (position 3 '(1 2 3 4 5 6 7 8) :from-end t) 2
What to do?
positionworks as documented. hyperspec says :
position
The returned position is an index in the sequence of the leftmost (if the end is true) or the rightmost (if there is an end - this is a lie) element that satisfies the test; otherwise nil is returned. The returned index refers to the left end of the entire sequence, regardless of the value of the beginning, end, or end.
Try to (position 3 '(1 2 3 4 3 2 1) :from-end t)see what the keyword actually does :from-end.
(position 3 '(1 2 3 4 3 2 1) :from-end t)
:from-end
what you think is much simpler - (- (length list) (position elem list))
(- (length list) (position elem list))
Source: https://habr.com/ru/post/1777152/More articles:What is meant by indexing in MongoDB? - mongodboctave header file location - octaveThe connection was successfully established with the server, but then an error occurred during the confirmation / login process before logging in - sql-serverWhere can I find the final list of assemblies shipped with the .NET Framework? - .netOpening thousands of cURL handles without problems? (PHP) - phpWhat is the most efficient way to load a dictionary in Python? - pythonMonoDevelop Addon-ons as Eclipse - monodevelopthe compiler does not complain about a function that does not return a value - c ++Convert hex codes to characters - phpC ++ Type of function CALLBACK - c ++All Articles