{"id":20690222,"url":"https://github.com/merck/generatedexpressions.jl","last_synced_at":"2025-09-02T04:35:19.343Z","repository":{"id":55402409,"uuid":"523030129","full_name":"Merck/GeneratedExpressions.jl","owner":"Merck","description":"A Julia package that implements a metalanguage to support expression comprehensions.","archived":false,"fork":false,"pushed_at":"2024-01-17T01:19:38.000Z","size":121,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-29T16:51:14.408Z","etag":null,"topics":["julia-language","metaprogramming"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Merck.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":"2022-08-09T16:37:18.000Z","updated_at":"2024-01-29T16:18:12.000Z","dependencies_parsed_at":"2024-11-17T00:20:10.043Z","dependency_job_id":null,"html_url":"https://github.com/Merck/GeneratedExpressions.jl","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/Merck%2FGeneratedExpressions.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merck%2FGeneratedExpressions.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merck%2FGeneratedExpressions.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merck%2FGeneratedExpressions.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Merck","download_url":"https://codeload.github.com/Merck/GeneratedExpressions.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250284110,"owners_count":21405288,"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":["julia-language","metaprogramming"],"created_at":"2024-11-16T23:12:17.741Z","updated_at":"2025-04-22T16:56:05.883Z","avatar_url":"https://github.com/Merck.png","language":"Julia","readme":"# GeneratedExpressions.jl: \u003cbr\u003e Expression Comprehensions in Julia\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#about\"\u003eAbout\u003c/a\u003e |\n  \u003ca href=\"#context-reactivedynamics\"\u003eContext\u003c/a\u003e |\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e |\n  \u003ca href=\"#showcase\"\u003eShowcase\u003c/a\u003e |\n  \u003ca href=\"https://merck.github.io/GeneratedExpressions.jl/\"\u003eDocumentation\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\nThe package implements a metalanguage to support code-less expression comprehensions in Julia. \n\nIn particular, we provide a convenient proxy (inspired by mustache.js's notation) which takes an expression (string, alternatively), interpolates the $s in the expressions from ranges provided at the input, and then amalgamates the generated expressions into a block, a tuple, etc. \n\nIt is possible to retrieve the generated expression (function `generate`) or to evaluate the expression in the caller's scope on the fly (macro `@generate`, `@fileval`).\n\n## Context: Dynamics of Value Evolution (DyVE)\n \nThe package is an integral part of the **Dynamics of Value Evolution (DyVE)** computational framework for learning, designing, integrating, simulating, and optimizing R\u0026D process models, to better inform strategic decisions in science and business.\n \nAs the framework evolves, multiple functionalities have matured enough to become standalone packages.\n \nThis includes **[ReactiveDynamics.jl](https://github.com/Merck/ReactiveDynamics.jl)**, a package which implements a category of reaction (transportation) network-type dynamical systems. The central concept of the package is of a stateful, parametric transition; simultaneous action of the transitions then evolves the dynamical system. Moreover, a network's dynamics can be specified using a compact modeling metalanguage.\n \nAnother package is **[AlgebraicAgents.jl](https://github.com/Merck/AlgebraicAgents.jl)**, a lightweight package to enable hierarchical, heterogeneous dynamical systems co-integration. It implements a highly scalable, fully customizable interface featuring sums and compositions of dynamical systems. In present context, we note it can be used to co-integrate a reaction network problem with, e.g., a stochastic ordinary differential problem!\n\n**[CEEDesigns.jl](https://github.com/Merck/CEEDesigns.jl)** is a decision-making framework for the cost-efficient design of experiments, with direct applications in drug research, healthcare, and various other fields. Typically, a design consists of multiple experiments. Each experiment is regarded as an option to acquire additional experimental evidence and is associated with a monetary cost and an execution time. The framework, then, aims to select experiments that balance the value of acquired information and the incurred costs.\n\n## Features\n\nAt the input is a general expression with (nested) expression comprehension atoms of the form `{\u003cexpression body\u003e, \u003csubstitution ranges\u003e, \u003clocal generator opts\u003e}`. The substitution ranges yield an iterator over substitution choices; by default, this is a product over the ranges and the ranges are evaluated in a sequential order from left to right. Use `zip=true` within `\u003clocal generator opts\u003e` to zip the iterators instead (Julia's standard zipping behavior).\n\nFor each substitution choice, expressions of the from `$sym` within `\u003cexpression body\u003e` are substituted with the respective choices (otherwise left unchanged). The resulting vector of expressions is either wrapped into 1) a block expression or 2) a call expression. In the latter case, the function's name is specified in `dlm=\u003ccall name\u003e`; additionally, `dlm=:(=)` is supported as well.\n\nNote that in the above process, the substitution happens at the expression level. It is likewise possible to input a string, perform string substitutions according to rules described above, and parse the resulting string into an expression. Because of the internal parsing, an expression body containing a comma has to be escaped by another pair of angle brackets (`\u003c` and `\u003e`).\n\nIn addition, both function and macro forms accept top-level generation opts: you may 1) provide singular substitution ranges with global effect (interpolates corresponding `$sym`s within the expression at the input) and 2) evaluate the macros before returning the expression (the usecase is bound to the function form).\n\n## Showcase\n\n### Function form: retrieve generated expression\n\n\n```julia-repl\njulia\u003e generate(\"{\\$a+\\$b, a=1:2, b=1:2}\") |\u003e println\n1+1\n1+2\n2+1\n2+2\n```\n\n```julia-repl\njulia\u003e generate(\"{\\$a+\\$b, a=1:3, b=1:\\$a}\") |\u003e println\n1+1\n2+1\n2+2\n3+1\n3+2\n3+3\n```\n\n```julia-repl\njulia\u003e generate(\"{\\$a+\\$b, a=1:2, b=1:2, zip=true}\") |\u003e println\n1+1\n2+2\n```\n\n\n```julia-repl\njulia\u003e generate(\"{\u003c\\$a+{\\$b, b=1:\\$a, dlm=+}\u003e, a=1:2}\") |\u003e println\n1+1\n2+1+2\n```\n\n\n```julia-repl\njulia\u003e generate(\"{\u003c\\$a+{\u003c\\$b+{\\$c, c=1:(\\$a+\\$b), dlm=+}\u003e, b=1:\\$a, dlm=+}\u003e, a=1:2}\") |\u003e println\n1+1+1+2\n2+1+1+2+3+2+1+2+3+4\n```\n\n\n```julia-repl\njulia\u003e generate(\"\"\"{\\$a, a=[\"str_\\$c\" for c in 1:2], dlm=\" \"}\"\"\") |\u003e println\nstr_1 str_2\n```\n\n### Macro form: evaluate generated expression\n\n\n```julia-repl\njulia\u003e @generate {$a+$b, a=1:3, b=1:2, zip=true, dlm=+}\n6\n```\n\n\n```julia-repl\njulia\u003e @generate {$a+$b, a=1:3, b=1:$a, dlm=+}\n24\n```\n\n\n```julia-repl\njulia\u003e N=2; @generate \"{\u003c\\$a+\\$b+\\$r\u003e, a=1:3, b=1:\\$a, r=N, dlm=+}\"\n36\n```\n\n\n```julia-repl\njulia\u003e a=b=c=1; @generate(\"{\u003c\\$[a,b,c]\u003e, dlm=+}\")\n3\n```\n\n\n```julia-repl\njulia\u003e write(\"file_expr.jl\", \"\"\"{println(\\$your_name, \", that is \", \\$name), name=[\"bot_\\$i\" for i in 1:2]}\"\"\")\n72\n\njulia\u003e @fileval file_expr.jl your_name=\"myself\"\nmyself, that is bot_1\nmyself, that is bot_2\n```\n\n\n```julia-repl\njulia\u003e write(\"file_string.jl\", \"\"\"{\u003cprintln(\"\\$your_name, that is \\$name\")\u003e, name=[\"bot_\\$i\" for i in 1:2]}\"\"\")\n70\n\njulia\u003e @fileval file_string.jl mode=string your_name=\"myself\"\nmyself, that is bot_1\nmyself, that is bot_2\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerck%2Fgeneratedexpressions.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerck%2Fgeneratedexpressions.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerck%2Fgeneratedexpressions.jl/lists"}