@@ -2495,7 +2495,7 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = {
24952495
24962496 /* TODO: dropwhile(cond:?DCallble)->?.
24972497 * Matches everything not matched by ?#takewhile:
2498- * >> function takeafter (cond: Callble): Sequence {
2498+ * >> function dropwhile (cond: Callble): Sequence {
24992499 * >> local iter = (this as Sequence).operator iter();
25002500 * >> foreach (local item: iter) {
25012501 * >> if (!cond(item)) {
@@ -2507,6 +2507,51 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = {
25072507 * >> yield item;
25082508 * >> } */
25092509
2510+ /* TODO: groupby(key:?DCallable)->?M?O?S?O
2511+ * Apply @key to every element of @this ?. and use the return value
2512+ * as a key into a mapping that will later be returned. Every item
2513+ * of that mapping is then another sequence containing all elements
2514+ * of @this for that same key. The order of elements within these
2515+ * sub-sequences matches the order of those elements in @this.
2516+ * >> function groupby(key: Callable): {Object: {Object...}} {
2517+ * >> // Actual impl doesn't use "Dict" and returns an abstract proxy instead
2518+ * >> local result = Dict();
2519+ * >> for (local item: this as Sequence) {
2520+ * >> result.setdefault(key(item), []).append(item);
2521+ * >> }
2522+ * >> return result;
2523+ * >> } */
2524+
2525+ /* TODO: partitionby(key?:?DCallable)->?S?T2?O?S?O
2526+ * Split @this ?. into many smaller, non-empty partition. A new partition
2527+ * is started between every 2 adjacent elements of @this for which @key
2528+ * returns a different value. When @key isn't given, `x -> x` is used.
2529+ * Returns {(PartitionKey, {PartitionItem...})...}
2530+ * >> function partitionby(key: Callable): {(Object, {Object...})...} {
2531+ * >> local iter = (this as Sequence).operator iter();
2532+ * >> foreach (local item: iter) {
2533+ * >> local currentPart = [item];
2534+ * >> local currentKey = key(item);
2535+ * >> foreach (item: iter) {
2536+ * >> local newKey = key(item);
2537+ * >> if (currentKey != newKey) {
2538+ * >> yield currentPart;
2539+ * >> currentPart = [];
2540+ * >> currentKey = newKey;
2541+ * >> }
2542+ * >> currentPart.append(item);
2543+ * >> }
2544+ * >> yield (currentKey, currentPart);
2545+ * >> break;
2546+ * >> }
2547+ * >> } */
2548+
2549+ /* TODO: get(index:?Dint,def:?O=!N)->?O
2550+ * Re-purpose the old (and long-deprecated) "get" function and have
2551+ * it implement the equivalent of Mapping.get, but for Sequence (i.e.
2552+ * be a high-level wrapper around "seq_operator_trygetitem" that
2553+ * returns "def" if "index" doesn't exist or isn't bound) */
2554+
25102555 /* TODO: pairwise->?S?T2?O?O
25112556 * Yield every element of @this sequence (except for the first) as a pair (predecessor, elem):
25122557 * >> property pairwise: {(Object, Object)...} = {
0 commit comments