Recent Changes - Search:

Oktatás

* Programozás 2
  + feladatsor
  + C feladatsor
  + Python feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

* levelezősök
  + Adator. prog.
  + feladatsor
  + quick link

teaching assets


Félévek

* 2024/25/1
* 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 ]

ranges

#############################

scala> 1 to 10
res85: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> 1 to 10 by 2
res86: scala.collection.immutable.Range = Range(1, 3, 5, 7, 9)

scala> 10 to 1
res87: scala.collection.immutable.Range.Inclusive = Range()

scala> 10 to 1 by -1
res88: scala.collection.immutable.Range = Range(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)

scala> 1 until 10
res89: scala.collection.immutable.Range = Range(1, 2, 3, 4, 5, 6, 7, 8, 9)

scala> (1 until 10).reverse
res90: scala.collection.immutable.Range = Range(9, 8, 7, 6, 5, 4, 3, 2, 1)

Alternatives:

scala> Range.inclusive(1, 10)
res91: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> Range.inclusive(1, 10, 3)
res92: scala.collection.immutable.Range.Inclusive = Range(1, 4, 7, 10)

scala> Range.inclusive(10, 1, -2)
res93: scala.collection.immutable.Range.Inclusive = Range(10, 8, 6, 4, 2)

Print numbers from 10 to 1:

scala> for (i <- 10 to 1 by -1) print(i + " ")
10 9 8 7 6 5 4 3 2 1
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 2015 March 14, 22:31