{"id":21415955,"url":"https://github.com/shahroz16/tilde","last_synced_at":"2026-05-20T03:32:22.370Z","repository":{"id":85571982,"uuid":"91687764","full_name":"Shahroz16/Tilde","owner":"Shahroz16","description":"A functional tool-belt for Kotlin Language similar to Lo-Dash or Underscore.js in Javascript and Dollar in Swift","archived":false,"fork":false,"pushed_at":"2017-07-10T10:22:05.000Z","size":160,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T05:41:28.810Z","etag":null,"topics":["belt","dollar","functional-programming","java-8","kotlin","lodash","underscore"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/Shahroz16.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":"2017-05-18T11:56:35.000Z","updated_at":"2025-01-12T06:54:04.000Z","dependencies_parsed_at":"2023-03-13T05:55:37.076Z","dependency_job_id":null,"html_url":"https://github.com/Shahroz16/Tilde","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahroz16%2FTilde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahroz16%2FTilde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahroz16%2FTilde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shahroz16%2FTilde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shahroz16","download_url":"https://codeload.github.com/Shahroz16/Tilde/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243918630,"owners_count":20368745,"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":["belt","dollar","functional-programming","java-8","kotlin","lodash","underscore"],"created_at":"2024-11-22T18:55:53.998Z","updated_at":"2026-05-20T03:32:22.341Z","avatar_url":"https://github.com/Shahroz16.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tilde\r\n----\r\nTilde is a functional tool-belt for Android. It not just only provides functional methods for Kotlin but also some wrapper for Java so you can play around with the library in Java too.\r\nTilde is inspired from [Dollar][dollar] in Swift which is similar to [Lodash][lodash] and [Underscore.js][underscore-js] in Javascript.\r\nIt also provides Java 6 and 7 users with almost all the useful methods in Java 8.\r\n\r\n\u003e **NOTE: This library is under development and documentation is incomplete**\r\n# Quick Jump\r\n---\r\n  - [Setup](#setup)\r\n  - [Usage](#usage)\r\n  - [Contributing](#contributing)\r\n  - [License](#license)\r\n\r\n# Setup\r\n---\r\n## Gradle Setup\r\nIn your **build.gradle** file, add the following dependency\r\n```groovy \r\ncompile 'com.tilde:tilde:1.0.0'\r\n```\r\n## Maven Setup\r\nAdd the following dependency\r\n```xml\r\n\u003cdependency\u003e\r\n    \u003cgroupId\u003ecom.tilde\u003c/groupId\u003e\r\n    \u003cartifactId\u003etilde\u003c/artifactId\u003e\r\n    \u003cversion\u003e1.0.0\u003c/version\u003e\r\n    \u003ctype\u003epom\u003c/type\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n# Usage\r\n----\r\n# Assign - `T?.assign`\r\nConsider a map where we have mapped characters to list of their occurences. e.g. in kotlin we have \r\n```kotlin\r\nval map = `mapOf('a' to arrayListOf(\"Apple\", \"Avocado\"), 'm' to arrayListOf(\"Mango\"), 't' to arrayListOf(\"Tomato\"))`\r\n```\r\nAnd we have a new value `Banana`. Our code would be like\r\n```kotlin\r\nval fruit = \"Banana\"\r\nval key = fruit.elementAt(0) // key is b here\r\nvar occurences = map.get(key)\r\nif (occurences == null) {\r\n    occurences = ArrayList\u003cString\u003e()\r\n    map.put(key, occurences)\r\n}\r\noccurences.add(fruit)\r\n```\r\nBut **Tilde** makes our life simple\r\n```kotlin\r\nval fruit = \"Banana\"\r\nval key = fruit.elementAt(0) // key is b here\r\nval occurences = map.get(key).assign {\r\n    // The block will only execute if map.get(key) returns null\r\n    val list =  ArrayList\u003cString\u003e()\r\n    map.put(key, list)\r\n    return@assign list\r\n}\r\noccurences.add(fruit)\r\n```\r\n# At - `Iterable.at`\r\nConsider we have a list \r\n```kotlin\r\nval list = arrayListOf(\"User first\", \"User second\", \"User third\", \"User fourth\", \"User fifth\")\r\n```\r\nAnd we want elements at 0th, 4th and 3rd index. We can get it simply by \r\n```kotlin\r\nval selected = list.at(0, 4, 3)\r\n// Selected here will be arrayListOf(\"User first\", \"User fifth\", \"User fourth\")\r\n```\r\n# Chunks - `Iterable.chunks`\r\nConsider we have list of students roll number\r\n```kotlin\r\nval list = arrayListOf(\"1001\", \"1002\", \"1003\", \"1004\", \"1005\", \"1006\", \"1007\", \"1008\", \"1009\", \"1010\", \"1011\", \"1012\", \"1013\", \"1014\")\r\n```\r\nAnd we want to create groups in sequence having maximum of 3 students. We can acheive this by the following code\r\n```kotlin\r\nval groups = list.chunks(3)\r\n```\r\nAnd here `groups` will have a 2D array as follows\r\n```\r\n1001    1002    1003\r\n1004    1005    1006\r\n1007    1008    1009\r\n1010    1011    1012\r\n1013    1014\r\n```\r\n\r\n# Range - `_t.range`\r\nCreates a list of numbers (positive and/or negative) progressing from start up to end\r\n```\r\n_t.range(end = 3)\r\n=\u003e listOf(0, 1, 2, 3)\r\n\r\n_t.range(start = 1, end = 5, endInclusive = false)\r\n=\u003e listOf(1, 2, 3, 4)\r\n\r\n_t.range(start = 1, end = 5, endInclusive = true)\r\n=\u003e listOf(1, 2, 3, 4, 5)\r\n\r\n_t.range(start = 0, end = 20, step = 5)\r\n=\u003e listOf(0, 5, 10, 15, 20)\r\n```\r\n\r\n# Reduce - `_t.reduce`\r\nReduce function that will resolve to one value after performing combine function on all elements\r\n```\r\n_t.reduce(listOf(1,2,3,4))\r\n=\u003e 10\r\n```\r\n\r\n# Remove - `Iterable.remove`\r\nRemoves items from an list.\r\n```\r\nval list = listOf(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\")\r\n_t.remove(list, \"a\", \"b\", \"f\")\r\n=\u003e result - listOf(\"c\", \"d\", \"e\")\r\n```\r\n\r\n# Contributing\r\n----\r\nFeel free to add new methods and submit a pull request. \r\n - Code\r\n - Add comments to your code (if necessary)\r\n - Add documentation to your methods\r\n - Not to forget adding test case for your methods\r\n - Add function usage in README.md\r\n - Generate pull request\r\n\u003e No **Pull Request** will be entertained without test cases\r\n\r\n# License\r\n----\r\n\r\n    MIT License\r\n    \r\n    Copyright (c) 2017 Shahroz Khan\r\n    \r\n    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n    \r\n    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n\r\n\r\n[dollar]: \u003chttps://github.com/ankurp/Dollar\u003e\r\n[lodash]: \u003chttps://lodash.com/\u003e\r\n[underscore-js]: \u003chttp://underscorejs.org/\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahroz16%2Ftilde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahroz16%2Ftilde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahroz16%2Ftilde/lists"}