{"id":20632896,"url":"https://github.com/jdevuyst/ruminant","last_synced_at":"2025-04-15T19:06:58.011Z","repository":{"id":27677884,"uuid":"31164087","full_name":"jdevuyst/ruminant","owner":"jdevuyst","description":"Swift persistent vectors à la Clojure","archived":false,"fork":false,"pushed_at":"2020-04-19T15:57:53.000Z","size":72,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T19:06:48.898Z","etag":null,"topics":["functional-data-structure","persistent-data-structure","persistent-vectors","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ryran/valine","license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdevuyst.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}},"created_at":"2015-02-22T13:39:08.000Z","updated_at":"2024-09-12T20:21:02.000Z","dependencies_parsed_at":"2022-09-03T03:42:48.699Z","dependency_job_id":null,"html_url":"https://github.com/jdevuyst/ruminant","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdevuyst%2Fruminant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdevuyst%2Fruminant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdevuyst%2Fruminant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdevuyst%2Fruminant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdevuyst","download_url":"https://codeload.github.com/jdevuyst/ruminant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249135808,"owners_count":21218365,"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":["functional-data-structure","persistent-data-structure","persistent-vectors","swift"],"created_at":"2024-11-16T14:17:44.651Z","updated_at":"2025-04-15T19:06:57.989Z","avatar_url":"https://github.com/jdevuyst.png","language":"Swift","readme":"# Ruminant\n\nA Swift implementation of [Clojure](http://clojure.org)'s [persistent](http://en.wikipedia.org/wiki/Persistent_data_structure) vectors.\n\n## Persistent Vectors\n\nCore operations such as `conj`, `assoc`, `get` (using subscripts), `subvec` (using subscripts), and `concat` have been implemented.\n\n```swift\nlet v: PersistentVector = [\"a\", \"b\", \"c\"]\nlet v2 = v.conj(\"d\").assoc(index: 2, \"C\")\nXCTAssertEqual(v, [\"a\", \"b\", \"c\"])\nXCTAssertEqual(v2, [\"a\", \"b\", \"C\", \"d\"])\nXCTAssert(v.pop() == v2[0..\u003c2])\nXCTAssertEqual(v.map {$0.uppercased()}, [\"A\", \"B\", \"C\"])\nXCTAssertEqual(v[1], \"b\")\nXCTAssertEqual(Array(v[1...2]), [\"b\", \"c\"])\n```\n\nTransient vectors are included:\n\n```swift\nlet v: PersistentVector = [\"a\", \"b\", \"c\"]\nvar tmp = v.transient()\ntmp = tmp.pop()\ntmp = tmp.conj(\"3\")\ntmp = tmp.conj(\"4\")\nXCTAssert(tmp.persistent() == [\"a\", \"b\", \"3\", \"4\"])\n```\n\n## Integration\n\nYou can use the Swift-Package manager to integrate Ruminant.\n\nAdd the following dependency in `Package.swift`:\n\n```swift\ndependencies: [\n.package(url: \"https://github.com/jdevuyst/ruminant\", from: \"1.0.7\")\n],\n```\n\n## Sample Usage\n\nHere is a sample walkthrough with Swift Package Manager to use this library.\n\nFirst, create a complete new directory from CLI named \"Sample\" and `cd` into it.\n\n```bash\nmkdir sample\ncd sample\n````\n\nNext, create a new exectuable swift template inside this directory.\n\n```bash\nswift package init --type executable\n```\n\nNow it's time to update `Package.swift`.\n\n```swift\n// swift-tools-version:4.0\n// The swift-tools-version declares the minimum version of Swift required to build this package.\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"sample\",\n    dependencies: [\n        // Dependencies declare other packages that this package depends on.\n        .package(url: \"https://github.com/jdevuyst/ruminant\", from: \"1.0.7\")\n    ],\n    targets: [\n        // Targets are the basic building blocks of a package. A target can define a module or a test suite.\n        // Targets can depend on other targets in this package, and on products in packages which this package depends on.\n        .target(\n            name: \"sample\",\n            dependencies: [\"ruminant\"])\n    ]\n)\n```\n\nLet's install the new dependency.\n\n```bash\nswift package update\n```\n\nWe'll also updatee `Main.swift` to test that Ruminant can be loaded.\n\n```swift\nimport ruminant\n\nprint(\"Hello, Persistent Vector!\")\n\nlet sample = PersistentVector([1,2,3,4]).conj(45).conj(42)\nprint(sample)\n```\n\nFinally, we can build and run the program from the command line.\n\n```bash\nswift build\nswift run\n\nHello, Persistent Vector!\n[1, 2, 3, 4, 45, 42]\n```\n\nThat's it. Enjoy the world of persistent datastructures!\n\n## License\n\nCopyright © 2015 Jonas De Vuyst\n\nDistributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdevuyst%2Fruminant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdevuyst%2Fruminant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdevuyst%2Fruminant/lists"}