Post AYEdmqBC9uKBwWNoEC by sofia@chaos.social
(DIR) More posts by sofia@chaos.social
(DIR) Post #AYEdmqBC9uKBwWNoEC by sofia@chaos.social
2023-07-30T13:49:47Z
1 likes, 0 repeats
does any #programmingLanguage have something like partial evaluation based on named parameters? so like #currying, but you can add the parameters in any order, and get a function back that that evaluates the still missing parameters?it seems pretty handy to me…here is an example for how i think this could work in #JS:
(DIR) Post #AYEdmvdNsWqOrObtMO by sofia@chaos.social
2023-07-30T14:09:28Z
0 likes, 0 repeats
the "//==" at the end of the example is supposed to be an "//>>" as well… i was thinking about changing the symbol and then reverted it and forgot that one. :P
(DIR) Post #AYEdodS2SAkh2u7KOO by stadtkind@lediver.se
2023-07-30T14:46:08Z
0 likes, 0 repeats
@sofia I really like the idea and I think I've seen it in some obscure logic language somewhere. I think it could be difficult to implement though, because it can only work for functions that are reversible regarding every parameter and I'm not aware of an elegant general solution to reverse functions, which would mean that you'd have to search for the fitting input to a given output.
(DIR) Post #AYEdoeAhm6TtHR100u by sofia@chaos.social
2023-07-30T15:04:32Z
0 likes, 0 repeats
@stadtkind hm, i think your'e imagining something more powerful than i do. i don't think anything about my idea requires reversibility, i just used a super simple function as an example.
(DIR) Post #AYEdoesJ9zMLSfPoye by stadtkind@lediver.se
2023-07-30T15:34:13Z
0 likes, 0 repeats
@sofia oh, you're right, I guess I projectet my wishes on your post ^^I thought you suggested to treat the result of the function as just another parameter so that you could do something like {speed = 10, time = 5} to get the distance traveled.
(DIR) Post #AYEdofjpwyB48gSZPc by TMakarios@theres.life
2023-07-30T23:23:12Z
1 likes, 0 repeats
@stadtkind @sofia If I recall correctly, #Prolog automatically reverses some reversible functions for you, though I think it mostly works with data structures like lists and trees; I'm not sure it would work with arithmetic functions, but perhaps you could make it work with arithmetic functions if you defined them for natural numbers represented in unary or something!