Text processing/Max licenses in use: Difference between revisions

→‎{{header|Scala}}: Roll back all of the unnecessary destructive edits to whitespace
m (Reverted edits by Cloudius (talk) to last revision by Gpapo)
(→‎{{header|Scala}}: Roll back all of the unnecessary destructive edits to whitespace)
Line 2,324:
2008/10/03_08:40:40
</pre>
 
=={{header|Scala}}==
 
=== Dumb imperative translations ===
The boolean logic e.g. is rather clumsy.
{{trans|Ada}}
{{trans|ALGOL 68}}
{{trans|AutoHotkey}}
{{trans|AWK}}
{{trans|Common Lisp}}
{{trans|E}}
{{trans|Fortran}}
{{trans|Go}}
{{trans|Python}}
{{trans|Java}}
{{trans|Julia}}
{{trans|MAXScript}}
{{trans|Nim}}
{{trans|OCaml}}
{{trans|Perl}}
{{trans|PL/I}}
{{trans|PureBasic}}
{{trans|R}}
{{trans|REXX}}
{{trans|Ruby}}
{{trans|Run BASIC}}
{{trans|Sidef}}
{{trans|Tcl}}
{{trans|Zcl}}
{{Out}}Best seen running in your browser [https://scastie.scala-lang.org/lTzl4t0cRFORGs9YWtvgAQ Scastie (remote JVM)].
<lang Scala>import java.io.{BufferedReader, InputStreamReader}
import java.net.URL
 
object License0 extends App {
val url = new URL("https://raw.githubusercontent.com/def-/nim-unsorted/master/mlijobs.txt")
val in = new BufferedReader(new InputStreamReader(url.openStream()))
 
val dates = new collection.mutable.ListBuffer[String]
var (count: Int, max: Int) = (0, Int.MinValue)
var line: String = _
 
while ( {line = in.readLine; line} != null) {
if (line.startsWith("License OUT ")) count += 1
if (line.startsWith("License IN ")) count -= 1 // Redundant test when "OUT"
if (count > max) { // Fruitless execution when "License IN "
max = count
val date = line.split(" ")(3)
dates.clear()
dates += date
} else if (count == max) {
val date = line.split(" ")(3)
dates += date
}
}
 
println("Max licenses out: " + max)
println("At time(s): " + dates)
 
}</lang>
{{in progress|lang=LANG|day=DD|month=MM|year=YYYY}}
//
 
=={{header|Sidef}}==
10,327

edits