{"id":24227629,"url":"https://github.com/egegungordu/zig-fsrs","last_synced_at":"2025-07-04T12:32:18.173Z","repository":{"id":247438187,"uuid":"825424662","full_name":"egegungordu/zig-fsrs","owner":"egegungordu","description":"Zig implementation of FSRS","archived":false,"fork":false,"pushed_at":"2024-07-11T15:30:35.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T02:58:35.556Z","etag":null,"topics":["fsrs","spaced-repetition-algorithm","zig","zig-library","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/egegungordu.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,"publiccode":null,"codemeta":null}},"created_at":"2024-07-07T18:23:37.000Z","updated_at":"2024-07-15T18:28:52.000Z","dependencies_parsed_at":"2024-07-08T20:29:27.857Z","dependency_job_id":"212cb19a-19f6-440e-8cd8-bb4e61cce183","html_url":"https://github.com/egegungordu/zig-fsrs","commit_stats":null,"previous_names":["egegungordu/zig-fsrs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/egegungordu/zig-fsrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egegungordu%2Fzig-fsrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egegungordu%2Fzig-fsrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egegungordu%2Fzig-fsrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egegungordu%2Fzig-fsrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egegungordu","download_url":"https://codeload.github.com/egegungordu/zig-fsrs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egegungordu%2Fzig-fsrs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260419305,"owners_count":23006249,"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":["fsrs","spaced-repetition-algorithm","zig","zig-library","zig-package"],"created_at":"2025-01-14T10:19:14.559Z","updated_at":"2025-06-17T18:35:03.029Z","avatar_url":"https://github.com/egegungordu.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-fsrs\n\nThis is an implementation of [FSRS-4.5](https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm) in Zig.  \nThis project is on zig 0.13.0\n\n```zig\nconst std = @import(\"std\");\nconst fsrs = @import(\"zig-fsrs\");\nconst Card = fsrs.Card;\n\npub fn main() !void {\n    var f = fsrs.FSRS.init(.{});\n    const initial_card = fsrs.Card.init();\n    var now = std.time.timestamp();\n\n    // schedule the initial card\n    var s = f.schedule(initial_card, now);\n\n    // good was selected on new card\n    const updated_card = s.select(.Good).card;\n\n    std.debug.print(\"initial card:\\n{}\\n\\n\", .{initial_card});\n    std.debug.print(\"after first rep (good):\\n{}\\n\\n\", .{updated_card});\n}\n```\n\n## Getting Started\n\n### 1. Add zig-fsrs to your own zig project:\n\nFetch zig-fsrs:\n\n```shell\nzig fetch --save git+https://github.com/egegungordu/zig-fsrs\n```\n\n### 2. Add zig-fsrs to your `build.zig` file:\n\n```zig\nconst zig_fsrs = b.dependency(\"zig-fsrs\", .{});\nexe.root_module.addImport(\"zig-fsrs\", zig_fsrs.module(\"zig-fsrs\"));\n```\n\nNow you can import zig-fsrs in your code:\n\n```zig\nconst fsrs = @import(\"zig-fsrs\");\n```\n\n## Basic Usage\n\n### 1. Create a new FSRS instance\n\n```zig\nvar f = fsrs.FSRS.init(.{});\n```\n\nThe parameters are optional. The parameters are:\n\n| Parameter         | Type    | Default Value                                                                                                                             |\n| ----------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| request_retention | f32     | 0.9                                                                                                                                       |\n| maximum_interval  | i32     | 36500                                                                                                                                     |\n| w                 | [17]f32 | { 0.4872, 1.4003, 3.7145, 13.8206, 5.1618, 1.2298, 0.8975, 0.031, 1.6474, 0.1367, 1.0461, 2.1072, 0.0793, 0.3246, 1.587, 0.2272, 2.8755 } |\n\n### 2. Create a new card\n\n```zig\nconst initial_card = fsrs.Card.init();\n```\n\n### 3. Schedule the card\n\n```zig\nconst review_time = std.time.timestamp();\nvar scheduled_cards = f.schedule(initial_card, review_time);\n```\n\n`schedule()` will return a `ScheduledCards` struct which contains the possible\ncards given the rating. To select a card, use the `select` method, which\nwill return a `ReviewedCard` struct.\n\n```zig\nconst good = scheduled_cards.select(.Good);\nconst new_card = good.card;\n```\n\n### Card fields\n\n| Field          | Type  | Description                                                                 |\n| -------------- | ----- | --------------------------------------------------------------------------- |\n| state          | State | The state of the card. Can be `New`, `Learning`, `Review`, or `Relearning`. |\n| reps           | i32   | The number of repetitions of the card.                                      |\n| lapses         | i32   | The number of times the card was remembered incorrectly.                    |\n| stability      | f32   | A measure of how well the card is remembered.                               |\n| difficulty     | f32   | The inherent difficulty of the card content.                                |\n| elapsed_days   | i64   | The number of elapsed days since the card was last reviewed.                |\n| scheduled_days | i64   | The next scheduled days for the card.                                       |\n| due            | i64   | The due date for the next review.                                           |\n| last_review    | i64   | The last review date of the card.                                           |\n\n## Examples\n\nTo run the examples:\n\n```shell\nzig build example -Dexample=example_name\n```\n\nCheck out the [examples](examples) directory for more examples.\n\n## Development\n\n```shell\ngit clone https://github.com/egegungordu/zig-fsrs.git\ncd zig-fsrs\n```\n\nTo run the tests:\n\n```shell\nzig build test --summary all\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegegungordu%2Fzig-fsrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegegungordu%2Fzig-fsrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegegungordu%2Fzig-fsrs/lists"}