core.logic

no way to unify the first of a seq to one lvar and the rest to another

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

would be nice to be able to do stuff like

(cond-m foo
(cons ?a nil) (println a))

where foo is some value, and (cons ?a nil) is pattern to match and (println a) is code to execute if it matches. (cons ?a nil) would match a sequence with one element, with ?a matching that one element.

you can sort of do this by modifying replace-lvar to turn (cons a b) into (lcons a b) this works for some cases but fails for the one given above, not sure why

Activity

Hide
Kevin Downey added a comment -

(cond-m '[(1)]
[(cons ?a nil)] a)

does actually return 1 if you making the change to replace-lvar my mistake

Show
Kevin Downey added a comment - (cond-m '[(1)] [(cons ?a nil)] a) does actually return 1 if you making the change to replace-lvar my mistake
Hide
Kevin Downey added a comment -

bd9a3440977ed17648d1e57fec2ba52c95657733 adds support for unifying first and rest using (?first ?second . ?rest)

Show
Kevin Downey added a comment - bd9a3440977ed17648d1e57fec2ba52c95657733 adds support for unifying first and rest using (?first ?second . ?rest)
Kevin Downey made changes -
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Resolution Completed [ 1 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: