SML - How to check if 2 parameters are the same in pattern matching? -


I have a piece of code that calories the Hanoi movement and gives it as a list, it works by now is.

  Funny Hanoi (0, Start, ZL) = [] | Hanoi (1, start, ZL) = [(1, start, ZL)] | Hanoi (Ange, Start, ZL) = Hanoi (Ange-1, Start, Hilf (Start, ZL)) @ ((Dye, Beginning, ZL) :: Hanoi (Anz-1, Hillef (Start, ZL), ZL) ) And Hilf (start, ZL) = 6- (start + ZL);  

Now my question is how can I check for the previous pattern in which the beginning and the goal (German: ZL) is the same? I tried to do something like this:

  | Hanoi (anz, start, ziel = start) = []  

but this does not work. It seems as if I have problems matching the concept of pattern perfectly. But I did not get a much more helpful source

Thank you in advance!

Generally, you do not check for this because start = ziel No pattern - pattern (for the most part) value or special code like _ or variable name, while start = ziel is an expression that is not fully evaluated goes.

Instead, match the pattern to remove start and ziel , and then you either for example:

 Depending on  or  start = ziel , if I have to do different things i hanoi (egg, start, zl) = if start = gil then ... and ...  

or

  | Hanoi (Dais, Start, ZL) = Case Start = true = GIL => ... | False = & gt; ...  

These two options work the same - using which is a stylish decision.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -