Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created June 6, 2021 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxandersen/55401c43a5b6dde30fa20eac732ee398 to your computer and use it in GitHub Desktop.
Save maxandersen/55401c43a5b6dde30fa20eac732ee398 to your computer and use it in GitHub Desktop.

sdk install jbang

touch list.jsh jbang --interactive --deps org.eclipse.collections:eclipse-collections-api:10.4.0 --deps org.eclipse.collections:eclipse-collections:10.4.0 list.jsh

//DEPS org.eclipse.collections:eclipse-collections-api:10.4.0
//DEPS org.eclipse.collections:eclipse-collections:10.4.0
import org.eclipse.collections.impl.factory.*;
var list = Lists.immutable.of(1,2,3,4,5,6,7,8,9).collect(i -> i*i);
// [1, 4, 9, 16, 25, 36, 49, 64, 81]
list.get(0) // 1
list.getFirst() // 1
list.getLast() // 81
list.min() // 1
list.max() // 81
list.sumOfInt(i -> i) // 285
//list.sortThis()
list.subList(1,3) // [4,9]
list.asReversed()
list.makeString("-") // 1-4-9-...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment