The simplest way to write decision workflows in Python. Python with a smart if. - sumanmichael/jevlang
1 comment
kazinator10 days ago
> ~ asks a question about a value and gets back a number or a label, never text. Here it is a probability, and the if fires at >= 0.5.
In other words this could be done in plain Python using:
if squiggle_probability(msg, "customer wants refund"):
...
else:
...
The ~ operator does not apply special evaluation rules to its argument expressions, and so can be a function, and that function can also roll in the probability thresholding (another closely-related function can return the raw probability).The Lisp rules of thumb about when to use macros and not to use them apply elsewhere, such as here, but are not well known.
Read the full thread on Hacker News →
Related stories
- Hacker News · 2 points · about 13 hours ago
- Lobsters · 22 points · about 10 years ago
- The Verge · 0 points · 1 day ago
- yieldfrom 1.0.0: A backport of the `yield from` semantic from Python 3.x to Python 2.7pypi.python.orgLobsters · 11 points · over 9 years ago
- Lobsters · 10 points · 6 months ago
- The smart home graveyard is getting crowdedtheverge.comThe Verge · 0 points · 4 days ago