From cff6bb77a3c316e848a449c3a0979c226e0a8727 Mon Sep 17 00:00:00 2001 From: PuqiAR Date: Mon, 22 Dec 2025 14:00:24 +0800 Subject: [PATCH] =?UTF-8?q?[Example]=E6=B7=BB=E5=8A=A0=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ExampleCodes/2-Function.fig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ExampleCodes/2-Function.fig diff --git a/ExampleCodes/2-Function.fig b/ExampleCodes/2-Function.fig new file mode 100644 index 0000000..9f3620c --- /dev/null +++ b/ExampleCodes/2-Function.fig @@ -0,0 +1,15 @@ +func greeting(name:String) -> String +{ + return "Hello " + name + "!"; +} + +const print := __fstdout_println; // link to std out +print(greeting("Fig")); + +func adder(x) +{ + return func (n) => x + n; // closure +} + +const add2 = adder(2); +print(add2(3)); \ No newline at end of file