var a = arrayOf(1,2,3); print(a.contentToString()) print(a.max()) print(a.min()) a.reverse()
creating hashmap
1 2 3
var ah= newHashMap<>(); ah.put(1,2);
1 2
var ah = hashMapOf(1 to 2, 2 to 3)
iterate lists with indices
java double colon :: operator acts as anonymous function
1 2 3 4 5 6 7 8 9 10 11 12
varl= a.listIterator(); while (l.hasNext()){ varindex= l.nextIndex(); varval= l.next(); System.out.println("INDEX: "+index+" ELEM: "+val); } IntStream.range(0,a.size()).forEach(index -> a.get(index)); var index=0; for (int i: a){ index++; }
1 2 3 4 5 6 7 8 9
a.forEachIndexed{ind, elem -> println("index? $ind"); println("elem? $elem")} for (var i in a.indices){ var elem = a[i] } a.indices.forEach { var elem = a[it] elem }
from jpype import * import jpype.imports # this is needed! shit. addClassPath("/root/Desktop/works/pyjom/tests/karaoke_effects/classpath/lingua.jar") startJVM(getDefaultJVMPath()) java.lang.System.out.println("Calling Java Print from Python using Jpype!") from com.github.pemistahl.lingua.api import * # detector = LanguageDetectorBuilder.fromAllLanguages().withLowAccuracyMode().build() detector = LanguageDetectorBuilder.fromAllLanguages().build() # 3.5GB just for detecting language! it is somehow crazy. sample = 'hello world' result = detector.detectLanguageOf(sample) print(result, type(result)) # <java class 'com.github.pemistahl.lingua.api.Language'> # but we can convert it into string. strResult = str(result) print(strResult, type(strResult)) import math print("CALLING MATH: %d" % math.sqrt(4)) shutdownJVM()