修改程序源码
actor { public func location(cities : [Text]) : async Text { return "Hello, from " # (debug_show cities) # "!"; }; public func location_pretty(cities : [Text]) : async Text { var str = "Hello from "; for (city in cities.vals()) { str := str # city #", "; }; return str # "bon voyage!"; } };public func apply<A, B>(fs : [A -> B], xs : [A]) : [B] { var ys : [B] = []; for (f in fs.vals()) { ys := append<B>(ys, map<A, B>(f, xs)); }; ys; };dfx deploydfx canister call favorite_cities location '(vec {"San Francisco";"Paris";"Rome"})'("Hello, from ["San Francisco", "Paris", "Rome"]!")dfx canister call favorite_cities location_pretty '(vec {"San Francisco";"Paris";"Rome"})'("Hello from San Francisco, Paris, Rome, bon voyage!")
Last updated
Was this helpful?