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

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ◇C++, ◇Clojure, ◇Scala


[ edit | logout ]
[ sandbox | passwd ]

all() and any()

all(), any()
s1 = "2026"
s2 = "2026-05-09"

print(s1.isdigit())  # True

print(s2.isdigit())  # False; contains '-' sign

a = True
b = True
c = False

print(all([a, b, c]))  # False

print(any([a, b, c]))  # True
import std/strutils    # isDigit
import std/sequtils    # toSeq(iter), map, filter
import std/sugar       # =>

let
  s1 = "2026"
  s2 = "2026-05-09"

echo s1.all(isDigit)    # true

echo s2.all(isDigit)    # false; contains '-' sign

let
  a = true
  b = true
  c = false

echo [a, b, c].all(x => x == true)   # false

echo @[a, b, c].any(x => x)   # true

In Python, isdigit() is a string method. It checks if every character is a digit.

In Nim, all() and any() are defined in std/sequtils:

proc all[T](s: openArray[T]; pred: proc (x: T): bool {.closure.}): bool {.effectsOf: pred.}

proc any[T](s: openArray[T]; pred: proc (x: T): bool {.closure.}): bool {.effectsOf: pred.}

all(): Iterates through a container and checks if every item fulfills the predicate.

any(): Iterates through a container and checks if at least one item fulfills the predicate.

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 2026 May 09, 09:48