Timeline for Less than Nothing
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 18, 2017 at 0:14 | history | tweeted | twitter.com/StackMma/status/842891876227301376 | ||
| Mar 17, 2017 at 17:59 | comment | added | b3m2a1 | use it around the entire pattern, e.g. nothing /: HoldPattern[List[a___, nothing, b__]] := List[a, b];. Prevents List[a___, nothing, b__] from evaluating to List[a___, b__] but matches List[a___, nothing, b__]. If you check the *Values for a function you'll see this is how they're stored. | |
| Mar 17, 2017 at 17:47 | answer | added | Alexey Popkov | timeline score: 5 | |
| Mar 17, 2017 at 17:31 | comment | added | Kvothe | @MB1965 Nice. Yes of course, great with the double underscores on one side and triple on the other so that "nothing" always vanishes if paired with something else, otherwise it would get stuck in the middle. How exactly do I use HoldPattern (if you have the time, otherwise I will find out on my own)? I take it the purpose would be to avoid evaluating the upvalues on the left hand side of definitions. | |
| Mar 17, 2017 at 17:21 | history | edited | Alexey Popkov | CC BY-SA 3.0 | added 26 characters in body |
| Mar 17, 2017 at 16:52 | comment | added | b3m2a1 | I don't think there's anything really built in, but a small tweak to your stuff will do it: nothing /: List[a__, nothing, b___] := List[a, b]; nothing /: List[a___, nothing, b__] := List[a, b];. Note the addition of triple underscores. That's actually important. By the way, you'll want to wrap those up-values in HoldPattern for if you want to tweak at all. | |
| Mar 17, 2017 at 16:40 | history | asked | Kvothe | CC BY-SA 3.0 |