Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions argparse/parser_positionals.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@

///|
fn positional_args(args : Array[Arg]) -> Array[Arg] {
let ordered = []
for arg in args {
if arg.info is PositionalInfo(_) {
ordered.push(arg)
}
}
ordered
[
for arg in args if arg.info is PositionalInfo(_) => arg
]
}

///|
Expand Down
10 changes: 3 additions & 7 deletions hashset/hashset.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,9 @@ pub fn[K] HashSet::iter(self : HashSet[K]) -> Iter[K] {
///|
/// Converts the hash set to an array.
pub fn[K] HashSet::to_array(self : HashSet[K]) -> Array[K] {
let arr = Array::new(capacity=self.size)
for entry in self.entries {
if entry is Some({ key, .. }) {
arr.push(key)
}
}
arr
[
for entry in self.entries if entry is Some({ key, .. }) => key
]
}

///|
Expand Down
6 changes: 1 addition & 5 deletions immut/sorted_set/immutable_set.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,7 @@ pub impl[A : Show] Show for SortedSet[A] with output(self, logger) {

///|
pub impl[A : ToJson] ToJson for SortedSet[A] with to_json(self) {
let capacity = self.iter().count()
guard capacity != 0 else { return Json::array([]) }
let jsons = Array::new(capacity~)
self.each(a => jsons.push(a.to_json()))
Json::array(jsons)
Json::array([ for a in self => a.to_json() ])
}

///|
Expand Down
8 changes: 1 addition & 7 deletions list/list.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,7 @@ pub impl[A : Show] Show for List[A] with output(xs, logger) {
/// ToJson implementation for List.
/// Converts a list to a JSON array.
pub impl[A : ToJson] ToJson for List[A] with to_json(self) {
let capacity = self.length()
guard capacity != 0 else { return [] }
let jsons = Array::new(capacity~)
for a in self {
jsons.push(a.to_json())
}
Json::array(jsons)
Json::array([ for a in self => a.to_json() ])
}

///|
Expand Down
12 changes: 6 additions & 6 deletions sorted_map/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
#deprecated("Use `keys_as_iter` instead. `keys` will return `Iter[K]` instead of `Array[K]` in the future.")
#coverage.skip
pub fn[K, V] SortedMap::keys(self : SortedMap[K, V]) -> Array[K] {
let keys = Array::new(capacity=self.size)
self.each((k, _v) => keys.push(k))
keys
[
for k, _ in self => k
]
}

///|
/// Return an iterator of values.
#deprecated("Use `values_as_iter` instead. `values` will return `Iter[V]` instead of `Array[V]` in the future.")
#coverage.skip
pub fn[K, V] SortedMap::values(self : SortedMap[K, V]) -> Array[V] {
let values = Array::new(capacity=self.size)
self.each((_k, v) => values.push(v))
values
[
for _, v in self => v
]
}
6 changes: 3 additions & 3 deletions sorted_map/map.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ pub fn[K, V] SortedMap::values_as_iter(self : SortedMap[K, V]) -> Iter[V] {
///|
/// Returns an array of all key-value pairs in ascending key order.
pub fn[K, V] SortedMap::to_array(self : SortedMap[K, V]) -> Array[(K, V)] {
let arr = Array::new(capacity=self.size)
self.each((k, v) => arr.push((k, v)))
arr
[
for kv in self => kv
]
}

///|
Expand Down
Loading