{"id":31072307,"url":"https://github.com/danielvartan/nlogo-utils","last_synced_at":"2025-09-16T00:44:42.707Z","repository":{"id":296528918,"uuid":"989877015","full_name":"danielvartan/nlogo-utils","owner":"danielvartan","description":"🧰 Utility Functions for NetLogo","archived":false,"fork":false,"pushed_at":"2025-07-14T23:03:19.000Z","size":90,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T00:51:59.681Z","etag":null,"topics":["agent-based-modeling","defensive-programming","modeling","netlogo","r-programming-language","simulations","utilities"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielvartan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2025-05-25T02:49:55.000Z","updated_at":"2025-08-26T18:26:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"d50ebbdc-2abc-4b69-9f56-8bb706d382f8","html_url":"https://github.com/danielvartan/nlogo-utils","commit_stats":null,"previous_names":["danielvartan/nlogo-utils"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielvartan/nlogo-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielvartan%2Fnlogo-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielvartan%2Fnlogo-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielvartan%2Fnlogo-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielvartan%2Fnlogo-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielvartan","download_url":"https://codeload.github.com/danielvartan/nlogo-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielvartan%2Fnlogo-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274601728,"owners_count":25315198,"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-09-11T02:00:13.660Z","response_time":74,"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":["agent-based-modeling","defensive-programming","modeling","netlogo","r-programming-language","simulations","utilities"],"created_at":"2025-09-16T00:44:40.981Z","updated_at":"2025-09-16T00:44:42.694Z","avatar_url":"https://github.com/danielvartan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# nlogo-utils\n\n\u003c!-- badges: start --\u003e\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![License: CC0-1.0](https://img.shields.io/badge/license-CC0_1.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\n`nlogo-utils` is a repository that I (Daniel Vartanian) use to store and organize my [NetLogo](https://ccl.northwestern.edu/netlogo/) utility functions (i.e., `to` and `to-report` [procedures](https://ccl.northwestern.edu/netlogo/docs/programming.html#procedures)).\n\nThis is primarily intended for personal use, but you are welcome to use it if you find it helpful. Please note that not all functions are documented.\n\n\u003e If you find this project useful, please consider giving it a star! \u0026nbsp; [![GitHub repo stars](https://img.shields.io/github/stars/danielvartan/nlogo-utils)](https://github.com/danielvartan/nlogo-utils)\n\n## How to Use\n\nAll functions are located in the `nlogo` directory. Each function resides in its own file named after the function, except for test, check, and assertion functions, which are grouped by category (for example, `check-integer.nls` contains `is-integer?`, `test-integer`, `check-integer`, and `assert-integer`).\n\nSome functions may require dependencies, such as NetLogo extensions or other functions. Any dependencies are listed in the file header.\n\nHere are some examples:\n\n### Control Flow and Logic\n\n- `any-member?` (`to-report`): Tests if any element in a list is a member of another list\n- `any-true?` (`to-report`): Tests if any element in a list is `true`\n- `list-any?` (`to-report`): Tests if any element in a list is equal to a specified value or to values in another list\n- `all-member?` (`to-report`): Tests if all elements in a list are members of another list\n- `all-true?` (`to-report`): Tests if all elements in a list are `true`\n- `list-all?` (`to-report`): Tests if all elements in a list are equal to a specified value or to values in another list\n\n### Defensive Programming\n\nThese functions follow NetLogo naming conventions for testing, as well as the conventions used in the [`checkmate`](https://mllg.github.io/checkmate/) R package.\n\n`test` functions return `true` or `false`. `check` functions return `true` if the test passes, or a string with an error message if it fails. `assert` functions are procedures (not reporters) that throw an error if the test fails.\n\n- `is-atomic?` `test-atomic` (`to-report`): Tests whether a value is not a list\n- `is-logical?` `test-logical` `test-boolean` (`to-report`): Tests whether a value is `true` or `false`\n- `is-integer?` `test-integer` (`to-report`): Tests whether a value is an integer number\n- `is-numeric?` `test-number` `test-numeric` (`to-report`): Tests whether a value is a number (integer or float)\n- `is-string?` `test-string` (`to-report`): Tests whether a value is a string\n- `is-list?` `test-list` (`to-report`): Tests whether a value is a list\n- `is-true?` `test-true` (`to-report`): Tests whether a value is `true`\n- `is-false?` `test-false` (`to-report`): Tests whether a value is `false`\n- `dir-exists?` `test-dir-exists` (`to-report`): Tests whether a directory exists\n- `test-file-exists` (`to-report`): Tests whether a file exists\n- `is-gis?` `test-gis` (`to-report`): Tests whether a value is a [GIS dataset](https://ccl.northwestern.edu/netlogo/docs/gis.html#gis:type-of)\n- `is-nan?` `test-nan` (`to-report`): Tests whether a value is `NaN` (not a number). This is useful when using the `gis` extension, as GIS datasets may contain `NaN` values.\n- `is-between?` `test-between` (`to-report`): Tests whether a value is between two numbers\n- `test-choice` (`to-report`): Tests whether a value is one of a set of choices\n- `is-windows?` `test-windows` (`to-report`): Tests whether the user is running NetLogo on a Windows operating system\n\n\u003cbr\u003e\n\n- `assert-atomic` (`to`): Asserts that a value is not a list\n- `assert-logical` `assert-boolean` (`to`): Asserts that a value is `true` or `false`\n- `assert-integer` (`to`): Asserts that a value is an integer\n- `assert-number` `assert-numeric` (`to`): Asserts that a value is a number (integer or float)\n- `assert-string` (`to`): Asserts that a value is a string\n- `assert-list` (`to`): Asserts that a value is a list\n- `assert-true` (`to`): Asserts that a value is `true`\n- `assert-false` (`to`): Asserts that a value is `false`\n- `assert-dir-exists` (`to`): Asserts that a directory exists\n- `assert-file-exists` (`to`): Asserts that a file exists\n- `assert-gis` (`to`): Asserts that a value is a [GIS dataset](https://ccl.northwestern.edu/netlogo/docs/gis.html#gis:type-of)\n- `assert-between` (`to`): Asserts that a value is between two numbers\n- `assert-choice` (`to`): Asserts that a value is one of a set of choices\n- `assert-windows` (`to`): Asserts that the user is running NetLogo on a Windows operating system\n\nSeveral other assertion functions are also available. Check the `nlogo` directory for more details.\n\n### File System\n\n- `basename` (`to-report`): Returns the base name of a file or directory (i.e., the last part of the path)\n- `file-path` (`to-report`): Creates a file path from a directory and a file name\n- `list-files-by-pattern` (`to-report`): Lists files in a directory that match a specified pattern\n- `normalize-path` (`to-report`): Normalizes a file path making it compatible with the user operating system\n\n### Lists\n\n- `as-list` (`to-report`): Converts an atomic value to a list\n- `collapse` (`to-report`): Collapses a list into a string using a separator (e.g., `[1 2 3 4]` → `\"1, 2, 3, 4\"`)\n- `combine` (`to-report`): Combines two lists into a single list\n- `list-to-c` (`to-report`): Converts a NetLogo list into a string formatted as an R `c()` expression, with elements separated by commas (e.g., `[1 2 3]` → `\"c(1, 2, 3)\"`)\n- `match` (`to-report`): Returns the first element in a list that matches a specified value\n- `unique-outliers` (`to-report`): Returns a sorted list of unique outlier values from a given list. Outliers are defined as values greater than the third quartile plus a specified multiple of the interquartile range (IQR), or less than the first quartile minus the same multiple of the IQR. Duplicate values are removed before identifying outliers.\n\n### Mathematical\n\n- `distance-between` (`to-report`): Returns the distance between two numbers\n- `quartile` (`to-report`): Returns the quartiles (Q1,Q2, Q3, Q4), the quartile length, and the interquartile range (IQR) of a list of numbers\n- `random-beta` (`to-report`): Returns a random number from a beta distribution with parameters `alpha` and `beta`\n- `rescale` (`to-report`): Rescales a number from one range to another\n\n### Strings\n\n- `as-string` (`to-report`): Converts any value to a string\n- `num-to-str-month` (`to-report`): Converts a numeric month value (`1` for January, `2` for February, etc.) to its corresponding string representation (e.g., `1` → `\"January\"`)\n- `rep-collapse` (`to-report`): Repeats and collapses a value into a string.\n- `single-quote` (`to-report`): Returns values with single quotes. It also works with lists.\n- `str-detect` (`to-report`): Detecs the presence/absense of a match in a string using a regular expression. Returns `true` if the match is found, `false` otherwise.\n- `str-extract` (`to-report`): Extracts a match from a string using a regular expression. Returns the first match found, or `\"NA\"` if no match is found.\n- `str-extract-all` (`to-report`): Extracts all matches from a string using a regular expression. Returns a list of all matches found, with `\"NA\"` for any non-matching elements.\n- `str-remove` (`to-report`): Removes a match from a string using a regular expression. Returns the string with the first match removed, or the original string if no match is found.\n- `str-remove-all` (`to-report`): Removes all matches from a string using a regular expression. Returns the string with all matches removed, or the original string if no matches are found.\n- `str-replace` (`to-report`): Replaces a match in a string using a regular expression. Returns the string with the first match replaced, or the original string if no match is found.\n- `str-replace-all` (`to-report`): Replaces all matches in a string using a regular expression. Returns the string with all matches replaced, or the original string if no matches are found.\n- `str-to-num-month` (`to-report`): Converts a string representing a month (e.g., `\"January\"`) to its corresponding numeric value (`1`  for January, `2` for February, etc.).\n- `test-string-in-r` (`to-report`): Tests whether a string is a valid R string.\n\n### World\n\n- `check-world-bleed` (`to-report`): Checks a range of `pxcor` and `pycor` values to identify any lines of patches with a value of `0`, `NA`, or `NaN`. Returns a list containing two ordered lists: one with the `pxcor` values and one with the `pycor` values of patches that meet this condition. If no such patches are found, both lists are empty.\n- `remove-world-bleed` (`to`): Checks for and removes world bleed patches—lines of patches at the edges of the world with values of `0`, `\"NA\"`, or `NaN`.\n- `show-values` (`to`): A procedure for use with a `forever` button that displays patch values under the mouse cursor in the NetLogo view. Useful for interactively inspecting patch data during model runs.\n\n## License\n\n[![License: CC0-1.0](https://img.shields.io/badge/license-CC0_1.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/)\n\nThe content is licensed under [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/), placing these materials in the public domain. You may freely copy, modify, distribute, and use this work, even for commercial purposes, without permission or attribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielvartan%2Fnlogo-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielvartan%2Fnlogo-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielvartan%2Fnlogo-utils/lists"}