{"id":16581718,"url":"https://github.com/kaushalmodi/ptr_math","last_synced_at":"2025-07-27T05:34:26.738Z","repository":{"id":44792139,"uuid":"369387056","full_name":"kaushalmodi/ptr_math","owner":"kaushalmodi","description":"Pointer arithmetic in Nim","archived":false,"fork":false,"pushed_at":"2021-11-01T13:43:21.000Z","size":240,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-25T10:04:00.534Z","etag":null,"topics":["arithmetic","c","ffi","nim","pointer"],"latest_commit_sha":null,"homepage":"https://kaushalmodi.github.io/ptr_math/","language":"Nim","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/kaushalmodi.png","metadata":{"files":{"readme":"README.org","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}},"created_at":"2021-05-21T02:01:30.000Z","updated_at":"2025-04-26T11:10:57.000Z","dependencies_parsed_at":"2022-09-19T07:41:12.993Z","dependency_job_id":null,"html_url":"https://github.com/kaushalmodi/ptr_math","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kaushalmodi/ptr_math","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fptr_math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fptr_math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fptr_math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fptr_math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaushalmodi","download_url":"https://codeload.github.com/kaushalmodi/ptr_math/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaushalmodi%2Fptr_math/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267306685,"owners_count":24067035,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["arithmetic","c","ffi","nim","pointer"],"created_at":"2024-10-11T22:29:44.837Z","updated_at":"2025-07-27T05:34:26.687Z","avatar_url":"https://github.com/kaushalmodi.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+title: Pointer Arithmetic in Nim\n#+author: Kaushal Modi\n\n[[https://github.com/kaushalmodi/ptr_math/actions/workflows/test.yml][https://github.com/kaushalmodi/ptr_math/actions/workflows/test.yml/badge.svg]]\n[[https://github.com/kaushalmodi/ptr_math/actions/workflows/docs.yml][https://github.com/kaushalmodi/ptr_math/actions/workflows/docs.yml/badge.svg]]\n\nThis module implements basic pointer arithmetic functionality.\n\n* Documentation\n[[https://kaushalmodi.github.io/ptr_math/][https://kaushalmodi.github.io/ptr_math/]]\n* Installation\n#+begin_example\nnimble install ptr_math\n#+end_example\n* Quick Start\n#+begin_src nim\nimport std/[strformat]\nimport ptr_math\n\nvar\n  a: array[0 .. 3, int]\n  p = addr(a[0])          # p is pointing to a[0]\n\nfor i, _ in a:\n  a[i] += i\necho \u0026\"before                    : a = {a}\"\n\np += 1                  # p is now pointing to a[1]\np[] = 100               # p[] is accessing the contents of a[1]\necho \u0026\"after p += 1; p[] = 100   : a = {a}\"\n\np[0] = 200              # .. so does p[0]\necho \u0026\"after p[0] = 200          : a = {a}\"\n\np[1] -= 2               # p[1] is accessing the contents of a[2]\necho \u0026\"after p[1] -= 2           : a = {a}\"\n\np[2] += 50              # p[2] is accessing the contents of a[3]\necho \u0026\"after p[2] += 50          : a = {a}\"\n\np += 2                  # p is now pointing to a[3]\np[-1] += 77             # p[-1] is accessing the contents of a[2]\necho \u0026\"after p += 2; p[-1] += 77 : a = {a}\"\n\necho \u0026\"a[0] = p[-3] = {p[-3]}\"\necho \u0026\"a[1] = p[-2] = {p[-2]}\"\necho \u0026\"a[2] = p[-1] = {p[-1]}\"\necho \u0026\"a[3] = p[0] = {p[0]}\"\n#+end_src\n\n* Development\n** Requirement\nThis library is tested using Nim /devel/ version. The version was\n1.5.1 as of writing this on \u003c2021-06-03 Thu\u003e.\n** Prep\nOnce you clone this repo, cd to the cloned directory and run the below\ncommand *first* (before you execute any of the below \"nim\" commands):\n#+begin_example\nnim pullConfig\n#+end_example\nThis will clone my global ~config.nims~ file into a\n~\u003crepo\u003e/nim_config/~ directory. That will enable running the ~nim\ntest~ and ~nim docs~ commands.\n** Testing\n#+begin_example\nnim test\n#+end_example\n** Generate doc\nCreate the HTML page and associated search index in ~\u003crepo\u003e/public/~.\n#+begin_example\nnim docs\n#+end_example\n\n* Credit\nMost of the code in this library is from [[https://forum.nim-lang.org/t/1188#7366][this code snippet]] authored by\nNim Forum user /Jehan/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaushalmodi%2Fptr_math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaushalmodi%2Fptr_math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaushalmodi%2Fptr_math/lists"}