datawire / quark

Quark is a specialized language for defining and implementing communication protocols in multiple languages.
http://datawire.github.io/quark/
Apache License 2.0
98 stars 24 forks source link

Quark Lists have convenience methods #229

Open bozzzzo opened 8 years ago

bozzzzo commented 8 years ago

All of these can be written in Quark (e.g., in the ListUtil<T> class), but that might not be the most efficient way to do so.

List<T>
  // Queries
  int indexOf(T value) -> lowest index of value in self, or -1 if not found
  bool contains(T value) -> indexOf(value) != -1
  int count(T value) -> 0..n number of times value is found in self

  // Ways to make new lists
  List<T> __add__(List<T> other) - concatenate
  List<T> __mul__(int count) - repeat
  List<T> copy() -> self * 1 - returns a new list that is a shallow copy of self

  // Ways to mutate self
  void extend(List<T> additional) - mutates self to be self + additional
  void reverse() - reverse