We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In reviewing documentation examples for HashMap, @digama0 mentioned that it would be nice to have syntax for constructing concrete HashMaps.
The proposed syntax is {"one" ↦ 2, "two" ↦ 2} => HashMap.ofList [("one", 1), ("two", 2)].
{"one" ↦ 2, "two" ↦ 2}
HashMap.ofList [("one", 1), ("two", 2)]
The text was updated successfully, but these errors were encountered:
I propose, #{"one" : 1, "two" : 2}
#{"one" : 1, "two" : 2}
Sorry, something went wrong.
@digama0 also gave the syntax invocations to accomplish this. Posted below for completeness:
import Std def Std.HashMap.ofList' [BEq α] [Hashable α] (l : List (α × β)) : HashMap α β := .ofList l open Lean syntax kvPair := term ": " term syntax "!{" (term ": " term),* "}" : term macro_rules | `(!{$[$k : $v],*}) => `(Std.HashMap.ofList' [$[($k, $v)],*]) #eval !{1: 2, 3: 4}.contains 1
No branches or pull requests
In reviewing documentation examples for HashMap, @digama0 mentioned that it would be nice to have syntax for constructing concrete HashMaps.
The proposed syntax is
{"one" ↦ 2, "two" ↦ 2}
=>HashMap.ofList [("one", 1), ("two", 2)]
.The text was updated successfully, but these errors were encountered: