public QNode Identify(QNode typedNode, Func <QNode, QNode> normalize)
        {
            var s         = typedNode.AsString();
            var interType = typedNode.C(0).P_("inter-type", "*").AsString();
            var f         = FunctionIndex.Find(s).OrEmpty().FirstOrDefault(_f => _f.Args.FirstOrDefault() == interType);

            if (f != null)
            {
                return(q.Q(typedNode.RawValue(), typedNode.C(0).W(q.Q("function-id", f.Id)), typedNode.Nodes().Skip(1).Select(child => normalize(child))));
            }
            return(typedNode);
        }
Esempio n. 2
0
 static ImmutableDictionary <string, User> Win(ImmutableDictionary <string, User> users, User user)
 {
     return(users.SetItem(user.Name, (users.Find(user.Name) ?? user).With(winRate: user.WinRate + 1)));
 }