2
docs說使用f.call.apply(arguments)
,但這似乎只適用於對象方法,而不是函數。如何在Dart中執行LISP(申請)?
testapply.dart:
#!/usr/bin/env dart
say(a, b, c) {
print("${a}!");
print("${b}!");
print("${c}!");
}
main() {
var args = [1, 2, 3];
say.call.apply(args);
}
跟蹤:
$ dart testapply.dart
'/Users/andrew/Desktop/testapply.dart': Error: line 11 pos 2: Unresolved identifier 'Function 'say': static.'
say.call.apply(args);
^
有沒有辦法做到LISP (apply f args)
沒有使用對象?
另外,有沒有辦法動態地包裝對象中的任意函數,以便它可以使用f.call.apply(arguments)
應用?
另外,可以飛鏢咖喱?
正如預感,做任何這些工作? 1.'say.apply(args)'2.'say(* args)' – 2012-02-16 16:44:14
@ ChrisJester-Young不,謝謝。 – mcandre 2012-02-16 16:45:24
巨大的無賴。星號是Python和Ruby中使用的,所以值得一試。好吧。 – 2012-02-16 16:51:34