Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2024/25/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

Index position of an element

See also std.algorithm.searching.

We're looking for an element in an array and we want to know where it is, at which index position.

(1) Where is it?
def main():
    li = [8, 5, 1, 3]

    # Where is 5? At which index position?
    idx = li.index(5)

    print(idx)  # 1

    print(li.index(99))  # ValueError exception (not found)
import std.stdio;
import std.algorithm.searching; // countUntil()

void main()
{
    int[] li = [8, 5, 1, 3];

    auto idx = li.countUntil(5);

    writeln(idx); // 1

    writeln(li.countUntil(99)); // -1 (not found)
}
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2025 June 29, 22:23