ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 10 Apr 2018 06:31:38 +0200Is there a command to find the place of an element in an array?https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/ For example, let v=[a, b, c, d]
I wonder if there is already encoded a function f such that f(a)=0, f(b)=1, f(c)=2..Fri, 30 Mar 2018 11:39:59 +0200https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/Answer by B r u n o for <p>For example, let v=[a, b, c, d]
I wonder if there is already encoded a function f such that f(a)=0, f(b)=1, f(c)=2..</p>
https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/?answer=41834#post-id-41834You can use `v.index(a)` to get the index of the first occurrence of `a`. An exception is raised if `a` is not in `v`. Fri, 30 Mar 2018 16:35:00 +0200https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/?answer=41834#post-id-41834Comment by logomath for <p>You can use <code>v.index(a)</code> to get the index of the first occurrence of <code>a</code>. An exception is raised if <code>a</code> is not in <code>v</code>. </p>
https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/?comment=41958#post-id-41958Tank you very muchTue, 10 Apr 2018 06:31:38 +0200https://ask.sagemath.org/question/41832/is-there-a-command-to-find-the-place-of-an-element-in-an-array/?comment=41958#post-id-41958