Skip to content

thread_as function ?? #540

Open
Open
@gkspranger

Description

@gkspranger

is there any way to achieve a "thread as" experience like there is in Clojure ??

https://clojuredocs.org/clojure.core/as-%3E

my goal is to be able to use the result from the previous evaluation, anywhere in the current evaluation .. i get that the "variable" declaration (v) could conflict with future args, but if i am allowed to "name" my variable and it is unique enough -- i could reasonably assume my positional arguments would be safe from conflicts ..

for example, i would hope to be able to do something like this ::

v = f"{uuid.uuid4()}some_variable_name_that_wont_collide_with_future_derived_vals"
def add(x, y): return x + y
def pow(x, y): return x**y

thread_as(
    1, v,
    (add, 4, v),
    (pow, v, 2),
)
# 25

if there is another way to achieve it -- i would love to hear it ..

thanks for the help !!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions