如何抵抗订购? [英] How to be resistant to ordering?
本文介绍了如何抵抗订购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出格式为 A,B,C
的输入,其中顺序不固定(例如,也可以使用 C,B,A
),我该如何解析字符串放入元组(a,b,c)
中,以便再次对结果进行排序?
Given input in form A,B,C
where the order is not fixed (eg C,B,A
might be possible too), how would I parse the string into a tuple (a,b,c)
so that the result is ordered again?
更大的例子:
输入A:
A 1
B 2
C 3
输入B:
C 3
B 2
A 1
解析器:
a = "A " *> decimal
b = "B " *> decimal
c = "C " *> decimal
如何编写一个解析器,为输入A和输入B提供(1,2,3)
.
How do I write a parser that will give (1,2,3)
for Input A and B.
我必须更确切地说:它们并非全是小数点...其他 choice
可能是这里的选择组合器.
I have to more exact: they aren't all decimals ... Else choice
would be the combinator of choice here.
推荐答案
您可以使用 查看全文