{"id":15495118,"url":"https://github.com/samchon/cagen","last_synced_at":"2025-04-22T20:27:56.460Z","repository":{"id":57192728,"uuid":"146697305","full_name":"samchon/cagen","owner":"samchon","description":"Number of Case Generator","archived":false,"fork":false,"pushed_at":"2023-09-22T07:13:55.000Z","size":58,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T10:06:44.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samchon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-08-30T04:51:55.000Z","updated_at":"2023-10-12T21:05:48.000Z","dependencies_parsed_at":"2024-02-03T18:15:09.349Z","dependency_job_id":null,"html_url":"https://github.com/samchon/cagen","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.125,"last_synced_commit":"eea67e9dc2c18368780d030bda285c8fae9e8ffc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samchon%2Fcagen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samchon%2Fcagen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samchon%2Fcagen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samchon%2Fcagen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samchon","download_url":"https://codeload.github.com/samchon/cagen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249519824,"owners_count":21285311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T08:16:09.964Z","updated_at":"2025-04-22T20:27:56.429Z","avatar_url":"https://github.com/samchon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cagen\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/cagen/blob/master/LICENSE)\n[![npm version](https://badge.fury.io/js/cagen.svg)](https://www.npmjs.com/package/cagen)\n[![Downloads](https://img.shields.io/npm/dm/cagen.svg)](https://www.npmjs.com/package/cagen)\n[![Build Status](https://github.com/samchon/cagen/workflows/build/badge.svg)](https://github.com/samchon/cagen/actions?query=workflow%3Abuild)\n\nNumber of Case Generator for TypeScript.\n\nSymbol                    | Class\n--------------------------|----------------------\nA x B x ... x Z           | CartesianProduct\nn!                        | Factorial\n\u003csub\u003en\u003c/sub\u003eP\u003csub\u003er\u003c/sub\u003e | Permutation\n\u003csub\u003en\u003c/sub\u003e∏\u003csub\u003er\u003c/sub\u003e | RepeatedPermutation\n\u003csub\u003en\u003c/sub\u003eH\u003csub\u003er\u003c/sub\u003e | RepeatedCombination\n\u003csub\u003en\u003c/sub\u003eC\u003csub\u003er\u003c/sub\u003e | Combination\n\n  - [API Documents](http://samchon.github.io/cagen/api)\n  - [Guide Documents](https://github.com/samchon/cagen/wiki)\n\n\n## Usage\n### Installation\n```bash\nnpm install --save cagen\n```\n\n### Common Features\n```typescript\nnamespace cagen.base\n{\n    export interface IForwardGenerator\n    {\n        // FREQUENCE ACCESSORS\n        size(): number;\n        begin(): Iterator;\n        end(): Iterator;\n\n        // ES2015, THEN FOR-OF ITERATION IS ALSO POSSIBLE\n        [Symbol.iterator]: IterableIterator\u003cnumber[]\u003e;\n    }\n\n    export interface Iterator\n    {\n        readonly value: number[];\n\n        next(): Iterator;\n        equals(obj: Iterator): boolean;\n    }\n}\n```\n\n```typescript\nimport { CartesianProduct } from \"cagen\";\n\nfunction main(): void\n{\n    let generator = new CartesianProduct(5, 4); // 5C4\n    console.log(\"n(5C4) =\", generator.size());\n\n    for (let it = generator.begin(); !it.equals(generator.end()); it = it.next())\n    {\n        let aCase: number[] = it.value;\n        console.log(\"  -\", aCase);\n    }\n}\nmain();\n```\n\n```typescript\nfor (let aCase of generator)\n    console.log(\"  -\", aCase);\n```\n\n### Random Accessor\n```typescript\nnamespace cagen.base\n{\n    export abstract class ArrayGenerator\n        implements IForwardGenerator\u003cIterator\u003e\n    {\n        at(index: number): Array\u003cnumber\u003e;\n    }\n}\n```\n\nMost of Case Generator classes, except combination classes, provide a random accessor `at()`. By that method `at()`, you can access to a specific case through not full iteration, but the special index number.\n\n  - Permutation\n  - Factorial\n  - RepeatedPermutation\n  - CartesianProduct\n  - ~~Combination~~\n  - ~~RepeatedCombination~~\n\n```typescript\nimport { Permutation } from \"cagen\";\n\nfunction main(): void\n{\n    let generator = new Permutation(7, 3);\n\n    console.log( generator.at(13) );\n    console.log( generator.at(31) );\n    console.log( generator.at(9999) ); // throw an std.OutOfRange error.\n}\nmain();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamchon%2Fcagen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamchon%2Fcagen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamchon%2Fcagen/lists"}