Wordle comparison: Difference between revisions
m
→{{header|Python}}: Slight reduction of main function, minor edits to comments.
m (→{{header|Python}}: Pruned out a redundant zip) |
m (→{{header|Python}}: Slight reduction of main function, minor edits to comments.) |
||
Line 454:
0 for for character not seen in the target
'''
)▼
return mapAccumL(amber)(
mapAccumL(green)(
)
)
)[1]
Line 467 ⟶ 466:
def green(residue, tg):
'''The existing residue of unmatched characters, tupled
with a character score of 2 if the target
and guess character match.
Otherwise, a residue (extended by the unmatched
character) tupled with a character score of 0.
'''
t, g = tg
Line 566 ⟶ 565:
{}
)
# first :: (a -> b) -> ((a, c) -> (b, c))
def first(f):
'''A simple function lifted to a function over a tuple,
with f applied only the first of two values.
return lambda xy: (f(xy[0]), xy[1])
Line 591 ⟶ 598:
f(a[0], x)
)
return lambda acc
nxt, xs, (acc, [])
)
|