tuple_map.carbon 461 B

12345678910111213141516171819
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. fn map[T:! type](f: __Fn (T) -> T, tuple: (T, T)) -> (T, T) {
  8. return (f(tuple[0]), f(tuple[1]));
  9. }
  10. fn inc(x: i32) -> i32 { return x + 1; }
  11. fn Main() -> i32 {
  12. return map(inc, (0, 2))[0];
  13. }
  14. // CHECK:STDOUT: result: 1