{"id":18616918,"url":"https://github.com/sile/charseq","last_synced_at":"2025-11-03T07:30:34.979Z","repository":{"id":66033747,"uuid":"654405","full_name":"sile/charseq","owner":"sile","description":null,"archived":false,"fork":false,"pushed_at":"2017-10-24T14:08:13.000Z","size":17,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-27T03:41:34.200Z","etag":null,"topics":["common-lisp"],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","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/sile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2010-05-07T02:56:49.000Z","updated_at":"2021-02-04T09:47:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"96e0025f-d26a-42c4-8f88-974fb2fc39e3","html_url":"https://github.com/sile/charseq","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fcharseq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fcharseq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fcharseq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fcharseq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/charseq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239412508,"owners_count":19634016,"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":["common-lisp"],"created_at":"2024-11-07T03:38:21.899Z","updated_at":"2025-02-18T04:58:06.001Z","avatar_url":"https://github.com/sile.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"charseq\n====================\nThis package provides **charseq** structure which represents an efficient character sequence.\n**charseq** is a wrapper of common-lisp standard string and it has following features:\n\n* Creating substring is very efficient.\n  * When creating a substring, **charseq** shares the source string instance and maintains start and end position of new string. Hence it is a constant time (and size) operation.\n* It is ensured that **charseq** instance always holds a _(simple-array character *)_ string as internal representation.\n  * _(simple-array character *)_ is one of the most efficient type that represents strings.\n\n\nVersion\n---------------\n0.1.9\n\n\nCompatibility\n---------------\n**chraseq** has no implementation-depended code, but it is highly optimized for SBCL(later 1.0.37) only.\n\n\nInstallation\n---------------\nUse asdf-install.\n\n```lisp\n* (require :asdf)\n* (require :asdf-install)\n* (asdf-install:install :charseq)\n```\n\n\nAPI\n---------------\n\n### [Types]\n--------------------------------------------------------------------------------\n#### charseq\nA charseq instance.\n\n#### index\nThe range of available string index.\n`(integer 0 #.array-total-size-limit)`\n\n\n### [Conditions]\n--------------------------------------------------------------------------------\n#### invalid-index-error\nIndicates the specified index is negative or exceeding target string size.\n\n#### bounding-indices-bad-error\nIndicates the specified indices (start and end position) are not within range of target string.\n\n\n### [Functions]\n--------------------------------------------------------------------------------\n#### (make string \u0026key start end) =\u003e charseq\nCreates new charseq instance from _string_.\n\n| name    | type            | default value   | description                 |\n|:-------:|:---------------:|----------------:|:----------------------------|\n| string  | string          |                 | Input source string. \u003cbr /\u003e If this type is _(simple-array character *)_, new charseq instance shares it. Otherwise charseq coerce input string to that's type and new instance  holds it. |\n| start   | charseq:index   |               0 | Start position of _charseq_ |\n| end     | charseq:index   | (length string) | End position of _charseq_   |\n| charseq | charseq:charseq |                 | Created charseq instance    |\n\nExample:\n```lisp\n* (charseq:make \"common lisp\")\n#S(CHARSEQ:CHARSEQ :STR \"common lisp\" :BEG 0 :END 11)\n\n* (charseq:make \"common lisp\" :start 1 :end 6)\n#S(CHARSEQ:CHARSEQ :STR \"common lisp\" :BEG 1 :END 6)\n\n* (charseq:to-string *)\n\"ommon\"\n\n* (charseq:= (charseq:make \"common lisp\" :start 1 :end 6)\n             (charseq:make (subseq \"common lisp\" 1 6)))\nT\n```\n\n--------------------------------------------------------------------------------\n#### (ref charseq index) =\u003e character\nAccesses the character of _charseq_ specified by _index_.\n\n| name      | type            | description             |\n|:---------:|:---------------:|:------------------------|\n| charseq   | charseq:charseq | Charseq instance        |\n| index     | charseq:index   | An index for the charseq |\n| character | character       | Referred character      |\n\nExample:\n```lisp\n* (charseq:ref (charseq:make \"common lisp\") 2)\n#\\m\n\n* (charseq:ref (charseq:make \"common lisp\" :start 6) 2)\n#\\i\n```\n\n--------------------------------------------------------------------------------\n#### (length charseq) =\u003e length\nReturns the length of _charseq_.\n\n| name    | type                   | description             |\n|:-------:|:----------------------:|:------------------------|\n| charseq | charseq:charseq        | Charseq instance        |\n| length  | integer                | the length of _charseq_ |\n\nExample:\n```lisp\n* (charseq:length (charseq:make \"common lisp\" :start 2 :end 5))\n3\n\n* (charseq:to-string (charseq:make \"common lisp\" :start 2 :end 5))\n\"mmo\"\n```\n\n--------------------------------------------------------------------------------\n#### (sub charseq start \u0026optional end) =\u003e sub-charseq\nCreates a charseq instance that is a subpart of _charseq_ bounded by _start_ and _end_.\nInternal string data is shared between _charseq_ and _sub-charseq_.\n\n| name        | type            | default value    | description                     |\n|:-----------:|:---------------:|-----------------:|:--------------------------------|\n| charseq     | charseq:charseq |                  | Source charseq instance         |\n| start       | charseq:index   |                  | Start position of _sub-charseq_ |\n| end         | charseq:index   | (length charseq) | End position of _sub-charseq_   |\n| sub-charseq | charseq:charseq |                  | Created charseq instance        |\n\nExample:\n```lisp\n* (defparameter *c0* (charseq:make \"common-lisp\"))\n*C0*\n\n* (defparameter *c1* (charseq:sub *c0* 1 10))\n*C1*\n\n* *c1*\n#S(CHARSEQ:CHARSEQ :STR \"common-lisp\" :BEG 1 :END 10)\n\n* (charseq:to-string *c1*)\n\"ommon-lis\"\n\n* (defparameter *c2* (charseq:sub *c1* 2 5))\n*C2*\n\n* *c2*\n#S(CHARSEQ:CHARSEQ :STR \"common-lisp\" :BEG 3 :END 6)\n\n* (charseq:to-string *c2*)\n\"mon\"\n```\n\n--------------------------------------------------------------------------------\n#### (to-string charseq \u0026optional start end) =\u003e string\nCreates a string that is a copy of the subpart of _charseq_ bounded by _start_ and _end_.\n\n| name    | type                       | default value    | description                 |\n|:-------:|:--------------------------:|-----------------:|:----------------------------|\n| charseq | charseq:charseq            |                  | Source charseq instance     |\n| start   | charseq:index              |                0 | Start position of _string_  |\n| end     | charseq:index              | (length charseq) | End position of _string_    |\n| string  | (simple-array character *) |                  | Created string              |\n\nExample:\n```lisp\n* (charseq:to-string (charseq:make \"common-lisp\"))\n\"common-lisp\"\n\n* (charseq:to-string (charseq:make \"common-lisp\") 3)\n\"mon-lisp\"\n\n* (charseq:to-string (charseq:make \"common-lisp\") 3 6)\n\"mon\"\n```\n\n--------------------------------------------------------------------------------\n#### (= charseq1 charseq1) =\u003e boolean\n#### (\u003e charseq1 charseq1) =\u003e boolean\n#### (\u003c charseq1 charseq1) =\u003e boolean\n#### (/= charseq1 charseq1) =\u003e boolean\n#### (\u003c= charseq1 charseq1) =\u003e boolean\n#### (\u003e= charseq1 charseq1) =\u003e boolean\nThese functions perform lexicographical order comparison of _charseq1_ and _charseq2_.\n\n\n### [Macros]\n--------------------------------------------------------------------------------\n#### (each (char-var charseq \u0026optional result-form) \u0026body body) =\u003e result\nThis macro iterates over the character of _charseq_.\n\n| name        | type             | default value | description\n|:-----------:|:----------------:|--------------:|:-------------\n| char-var    | symbol(variable) |               | In each iteration, the focused character is bound to this variable |\n| charseq     | charseq:charseq  |               | Input charseq instance                                             |\n| result-form | T                |           nil | After the iteration, this form is evaluated as the result          |\n| body        | T*               |               | The body is executed once for each character in the _charseq_      |\n\nExample:\n```lisp\n* (defparameter *c* (charseq:make \"common-lisp\" :start 3 :end 8))\n*C*\n\n* (charseq:each (char *c* 'done)\n    (print (list :char char)))\n(:CHAR #\\m)\n(:CHAR #\\o)\n(:CHAR #\\n)\n(:CHAR #\\-)\n(:CHAR #\\l)\nDONE\n```\n\n--------------------------------------------------------------------------------\n#### (as-string (string-var start-var end-var) charseq \u0026body body) =\u003e result\nThis macro binds the internal state of _charseq_ to _string-var_, _start-var_, and _end-var_, then executes _body_.\n\n| name       | type             | description                                                              |\n|:----------:|:----------------:|:-------------------------------------------------------------------------|\n| string-var | symbol(variable) | The internal string data of _charseq_ is bound to this variable          |\n| start-var  | symbol(variable) | The start position of _charseq_ is bound to this variable                |\n| end-var    | symbol(variable) | The end position of _charseq_ is bound to this variable                  |\n| charseq    | charseq:charseq  | Input charseq instance                                                   |\n| body       | T*               | Any expressions. the scope of bound variables is limited in this _body_. |\n| result     | T                | Executed result of _body_                                                |\n\nExample:\n```lisp\n* (defparameter *c* (charseq:make \"common-lisp\" :start 3 :end 8))\n*C*\n\n* (charseq:as-string (str start end) *c*\n    (print (list str start end))\n    'done)\n(\"common-lisp\" 3 8)\nDONE\n```\n\n--------------------------------------------------------------------------------\n#### (with-dynamic-extent (charseq-var string \u0026key start end) \u0026body body) =\u003e result\n\nThe semantics of this macro is almost equivalent to the following expression:\n```lisp\n(let ((charseq-var (charseq:make :start start :end end)))\n  (declare (dynamic-extent charseq-var))\n  ,@body)\n```\nOn SBCL, the value of _charseq-var_ will be allocated on the stack instead of the heap.\nIn that case, the cost of creating charseq instance (from _(simple-array character *)_ string) will be almost negligible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Fcharseq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Fcharseq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Fcharseq/lists"}