<< Back to previous view

[MATCH-39] Allow matching of map expressions to restrict the set of keys present in the value to a subset of a specified set of keys Created: 21/Nov/11  Updated: 28/Jul/13  Resolved: 02/Jun/13

Status: Closed
Project: core.match
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Hugo Duncan Assignee: David Nolen
Resolution: Duplicate Votes: 0
Labels: None


It is useful, to be able to constrain a match on a map value to limit the set of keys present in the value, without enforcing that the keys are all present in the value.

The current :only option, enforces a strict matching of keys.

{{(let [x {:a 1} (match [x] [({:a _ :b _} :only [:a :b])])}} => doesn't match

This came up trying to write a precondition on the argument of a function, which allowed optional keys, but wanted to restrict the overall set of keys.

Comment by David Nolen [ 21/Nov/11 12:22 PM ]
(match x
  ({:c 1} :has [:a :b]) :a0


(match x
  ({:c 1} :contains [:a :b]) :a0

Seems reasonable.

Comment by David Nolen [ 21/Nov/11 12:34 PM ]

Ah misunderstood. You want something like :allowed.

Comment by David Nolen [ 02/Jun/13 11:36 AM ]

This is a variant of MATCH-70. You can not specify that some keys must be present by specifying the key and the specifying that the value of the key is a wildcard.

Generated at Mon Jan 22 18:32:35 CST 2018 using JIRA 4.4#649-r158309.