From 14ee87af66d4ca8b5c62aceed627df197f950f04 Mon Sep 17 00:00:00 2001 From: haifenghuang Date: Thu, 26 Apr 2018 22:40:03 +0800 Subject: [PATCH] Update README --- README.md | 14 ++++++++++++++ README_cn.md | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index c7367d8..81c2fa0 100644 --- a/README.md +++ b/README.md @@ -666,6 +666,20 @@ let hh = =^10 // Use the '=^' prefix operator printf("hh=%d\n", hh) // result: hh=-10 ``` +```swift +fn .^(x, y) { + arr = [] + while x <= y { + arr += x + x += 2 + } + return arr +} + +let pp = 10.^20 +printf("pp=%v\n", pp) // result: pp=[10, 12, 14, 16, 18, 20] +``` + Below is a list of predefined operators and user defined operators: diff --git a/README_cn.md b/README_cn.md index 3976597..f2ca89a 100644 --- a/README_cn.md +++ b/README_cn.md @@ -667,6 +667,20 @@ let hh = =^10 // 使用用户自定义的前缀运算符'=^' printf("hh=%d\n", hh) // 结果: hh=-10 ``` +```swift +fn .^(x, y) { + arr = [] + while x <= y { + arr += x + x += 2 + } + return arr +} + +let pp = 10.^20 +printf("pp=%v\n", pp) // result: pp=[10, 12, 14, 16, 18, 20] +``` + 下面的表格列出了Monkey内置的运算符和用户可以自定义的运算符: