0
Ich las this Artikel und ich über die folgenden zwei Funktionen kamen:Was ist das Schlüsselwort "const" in Swift?
// Sequence actions, discarding the value of the second argument
func <* <A, B>(p: Parser<A>, q: Parser<B>) -> Parser<A> {
return const <^> p <*> q
}
// Sequence actions, discarding the value of the first argument
func *> <A, B>(p: Parser<A>, q: Parser<B>) -> Parser<B> {
return const(id) <^> p <*> q
}
Was sind die const
und const(id)
? Ich vermute, dass es sich um Werte handelt, aber welche Werte? Sind sie implizite links- oder rechtsseitige Operanden? (Dies ist nur eine Einstellung im Dunkeln). Ich konnte keine Informationen darüber finden.
Ich glaube, diese Funktionen in seinem Parser sind nicht Teil der Stiftung. – Rob
@Rob ah das würde Sinn machen! –
https://github.com/tryswift/TryParsec/blob/4dc2cadc23311fc27dbcbd108727bab46905e229/Sources/TryParsec/Prelude.swift#L7 – Hamish