Skip to main content

Timeline for Transform a rule to a list of rules

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Apr 13, 2017 at 12:56 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Nov 14, 2014 at 21:17 comment added higgy This answers my question. I forgot that x -> y could be expressed as Rule[x,y], and therefore be used with Thread.
Nov 14, 2014 at 21:16 vote accept higgy
Nov 14, 2014 at 20:40 comment added higgy In chat. Any way to freeze this question until after we've chatted?
Nov 14, 2014 at 20:36 comment added Szabolcs @higgy No, it's not necessary. I think we're having a communication breakdown. Why don't you join chat?
Nov 14, 2014 at 20:35 comment added Szabolcs @higgy You don't need to know the first part of the rule to apply Thread to it. If you have x = a -> {1,2,3} then you can just use Thread[x], no need to know what's inside x, other than that it's a rule with a list on the RHS. Can you give an example input and a corresponding example output? I thought a -> {1, 2, 3} and {a -> 1, a -> 2, a -> 3} could be considered such. Thread takes you from one to the other.
Nov 14, 2014 at 20:34 comment added higgy If extracting the left-hand side is a necessary step in all possible solutions to this question, then edit your answer I and will accept it. I'm also curious as to whether there are solutions that don't require extracting the left-hand side first, i.e., something more direct.
Nov 14, 2014 at 20:29 comment added Szabolcs @higgy a -> b is just an alternate notation for Rule[a,b], so you can extract a using First, Part, Extract, etc. See here: reference.wolfram.com/language/tutorial/PartsOfExpressions.html
Nov 14, 2014 at 20:27 comment added higgy How would this be done without knowing that "a" is "a". In your answer, you refer to "a" in your code. I'll update the question to make it clearer. A related question would be: How do you extract the left-hand side of a rule efficiently?
Nov 14, 2014 at 20:25 history answered Szabolcs CC BY-SA 3.0