diff --git a/01-SendingAndStandardOut/README.md b/01-SendingAndStandardOut/README.md index 87d8be6..3de8d45 100644 --- a/01-SendingAndStandardOut/README.md +++ b/01-SendingAndStandardOut/README.md @@ -13,7 +13,7 @@ There is a long-standing tradition in programming that your first program should Make the program print "Rholang rocks!" instead of "Hello World". -## WTH is stdout? +## WTH is result? ![Channels are like mailboxes for sending messages](mailbox.png) @@ -21,14 +21,14 @@ The heart of rholang is communicating on channels. Channels are communication li ![Redo this diagram!](sendSyntax.png) -We created the channel `stdout` on the first line of the program with `new stdout`. You'll create lots of channels as you learn rholang. We also gave our channel a special power by including `(rho:io:stdout)`. More on that later, but for now just know that you need that part in parentheses to make text actually appear on the screen. +We created the channel `result` on the first line of the program with `new result`. You'll create lots of channels as you learn rholang. The first new channel defined will be returned as the result of an explore deploy. More on that later, but for now just know that you need that the first channel name will give you a result of an explore. For an actual deploy onto the blockchain the value retuned will be on a special deployId channel. ## Using other channels ![Sent messages wait to be received here in "message purgatory"... JK, it's called the "tuplespace"](mailboxes.png) -You can actually send messages on lots of channels, not just `stdout`. But unlike `stdout` they won't display on the screen because we won't add any special powers to them. +You can actually send messages on lots of channels, not just `result`. But unlike `result` they won't display on the screen because we won't add any special powers to them. [tupleSpace.rho](tupleSpace.rho) @@ -66,9 +66,9 @@ Print two messages, "Rick" and "Morty", on the screen in one program. ## Quiz -What will `stdout!("Programming!")` print to the screen? +What will `result!("Programming!")` print to the screen? - [x] Programming! -- [ ] stdout! +- [ ] result! - [ ] Nothing @@ -76,14 +76,14 @@ What channel does `what!("Up")` send a message on? - [ ] `Up` - [x] `what` - [ ] `what` -- [ ] `stdout` +- [ ] `result` Which does rholang do first in ``` -stdout!("Dogs") +result!("Dogs") | -stdout!("Cats") +result!("Cats") ``` - [ ] prints "Dogs" - [ ] prints "Cats" diff --git a/01-SendingAndStandardOut/README_CN.md b/01-SendingAndStandardOut/README_CN.md index c13d710..fe07fa5 100644 --- a/01-SendingAndStandardOut/README_CN.md +++ b/01-SendingAndStandardOut/README_CN.md @@ -72,9 +72,9 @@ Storage Contents: ## 小测试 -`stdout!("Programming!")` 将在屏幕上输出什么? +`result!("Programming!")` 将在屏幕上输出什么? - [x] Programming! -- [ ] stdout! +- [ ] result! - [ ] Nothing diff --git a/01-SendingAndStandardOut/README_RU.md b/01-SendingAndStandardOut/README_RU.md index 22b05f6..52d463a 100644 --- a/01-SendingAndStandardOut/README_RU.md +++ b/01-SendingAndStandardOut/README_RU.md @@ -77,9 +77,9 @@ Storage Contents: ## Тест -Что выведет на экран фраза `stdout!("Programming!")` ? +Что выведет на экран фраза `result!("Programming!")` ? - [x] Programming! -- [ ] stdout! +- [ ] result! - [ ] Ничего diff --git a/01-SendingAndStandardOut/hello.rho b/01-SendingAndStandardOut/hello.rho index f0afa39..abb32c7 100644 --- a/01-SendingAndStandardOut/hello.rho +++ b/01-SendingAndStandardOut/hello.rho @@ -1,3 +1,3 @@ -new stdout(`rho:io:stdout`) in { - stdout!("Hello World!") +new result in { + result!("Hello World!") } diff --git a/01-SendingAndStandardOut/parallel.rho b/01-SendingAndStandardOut/parallel.rho index 1217bf1..d2d971c 100644 --- a/01-SendingAndStandardOut/parallel.rho +++ b/01-SendingAndStandardOut/parallel.rho @@ -1,5 +1,5 @@ -new chan1, stdout(`rho:io:stdout`) in { - stdout!("I'm on the screen") +new result, chan1 in { + result!("I'm on the screen") | chan1!("I'm in the tuplespace") } diff --git a/02-Receiving/README.md b/02-Receiving/README.md index 8362988..9a25de2 100644 --- a/02-Receiving/README.md +++ b/02-Receiving/README.md @@ -19,7 +19,7 @@ BTW, lines that start with `//` are called comments. They're just there for huma ![Pizza shop can receive messages on its channel.](pizza.png) -The following code sends a message on a channel for a pizza shop and the pizza shop receives it. The pizza shop acknowledges receiving the message by printing to `stdout`. +The following code sends a message on a channel for a pizza shop and the pizza shop receives it. The pizza shop acknowledges receiving the message by printing to `result`. [pizzaOrder](pizzaOrder.rho) diff --git a/02-Receiving/coffeeShop.rho b/02-Receiving/coffeeShop.rho index 22dacf9..7425f3c 100644 --- a/02-Receiving/coffeeShop.rho +++ b/02-Receiving/coffeeShop.rho @@ -1,6 +1,6 @@ -new coffeeShop, stdout(`rho:io:stdout`) in { +new result, coffeeShop in { contract coffeeShop(order) = { - stdout!("Coffee Order Received") + result!("Coffee Order Received") } | coffeeShop!("one hot chocolate") diff --git a/02-Receiving/persistentPizzaShop.rho b/02-Receiving/persistentPizzaShop.rho index 707c252..a89e6e4 100644 --- a/02-Receiving/persistentPizzaShop.rho +++ b/02-Receiving/persistentPizzaShop.rho @@ -1,6 +1,6 @@ -new pizzaShop, stdout(`rho:io:stdout`) in { +new result, pizzaShop in { for (order <= pizzaShop) { - stdout!("Pizza Order Received") + result!("Pizza Order Received") } | pizzaShop!("one hot chocolate") diff --git a/02-Receiving/pizzaOrder.rho b/02-Receiving/pizzaOrder.rho index b6a554a..ff81fbd 100644 --- a/02-Receiving/pizzaOrder.rho +++ b/02-Receiving/pizzaOrder.rho @@ -1,7 +1,7 @@ -new pizzaShop, stdout(`rho:io:stdout`) in { +new result, pizzaShop in { pizzaShop!("2 medium pies") | for(order <- pizzaShop){ - stdout!("Order Received.") + result!("Order Received.") } } diff --git a/03-TelephoneNamesAndProcesses/README.md b/03-TelephoneNamesAndProcesses/README.md index 724ce5d..3aa21f0 100644 --- a/03-TelephoneNamesAndProcesses/README.md +++ b/03-TelephoneNamesAndProcesses/README.md @@ -16,7 +16,7 @@ As the message says, you learn most when you experiment. So be sure to change th ### Exercise -That telephone game was fun, but it's always better the have more players. Go ahead and add a third player called Charlie. Instead of printing to `stdout`, bob will send the message along to Charlie. Then Charlie will print it to the screen. The More the Merrier! +That telephone game was fun, but it's always better the have more players. Go ahead and add a third player called Charlie. Instead of printing to `result`, bob will send the message along to Charlie. Then Charlie will print it to the screen. The More the Merrier! @@ -38,7 +38,7 @@ Did you notice the `*` in `bob!(*message)`? In rholang there are two kinds of th A "process" is any piece of rholang code such as our telephone game, or our pizza shop order program. Processes can be big hundred-line programs or small on-liners. They can even be tiny pieces of code that are just values. Here are some example processes. - - `stdout!("Sup Rholang?")` A common send + - `result!("Sup Rholang?")` A common send - `Nil` The smallest possible process. It literally means "do nothing". - `for(msg <- phone){Nil}` A common receive that does nothing when a message arrives. - `"Hello World"` Another small process that also does nothing. These are called "Ground Terms". @@ -121,7 +121,7 @@ What is `@@Nil`? - [ ] `@"BobsPhone"` - [ ] `*"BobsPhone"` - [ ] `@*"BobsPhone"` -- [ ] `stdout!("BobsPhone")` +- [ ] `result!("BobsPhone")` @@ -131,4 +131,4 @@ What is `@@Nil`? Instead of a linear telephone game where each player passes the message to the next, let's add a branch in the game. So now Bob will send to Charlie like before, but Bob will also send to Dawn. -Each branch can be as long as you want, but at the end of each branch, print the message to `stdout`. +Each branch can be as long as you want, but at the end of each branch, print the message to `result`. diff --git a/03-TelephoneNamesAndProcesses/README_CN.md b/03-TelephoneNamesAndProcesses/README_CN.md index 1e573e5..8aeef29 100644 --- a/03-TelephoneNamesAndProcesses/README_CN.md +++ b/03-TelephoneNamesAndProcesses/README_CN.md @@ -39,7 +39,7 @@ "processes"可以是rholang中任何一个代码片段,例如我们的传话筒游戏,或者是披萨店订单程序。“process”可以是上百行的大程序,也可以只有几行。它们甚至可以是用于表示值的代码。下面是一些“process”的例子。 - - `stdout!("Sup Rholang?")` 一个常见的发送操作。 + - `result!("Sup Rholang?")` 一个常见的发送操作。 - `Nil` 最小的“process”。如字面意思,它不做任何事。 - `for(msg <- @"phone"){Nil}` 一个常见的接收操作,在消息到达时它不会做任何事。 - `"Hello World"` 另一个不做任何事请的小“process”。被称为"基础术语"。 @@ -123,7 +123,7 @@ Aice通过`for(message <- @"Alice")`接收我们的消息,所以, `message` - [ ] `@"BobsPhone"` - [ ] `*"BobsPhone"` - [ ] `@*BobsPhone` -- [ ] `stdout!("BobsPhone")` +- [ ] `result!("BobsPhone")` diff --git a/03-TelephoneNamesAndProcesses/README_RU.md b/03-TelephoneNamesAndProcesses/README_RU.md index 8ac23c8..8b023ee 100644 --- a/03-TelephoneNamesAndProcesses/README_RU.md +++ b/03-TelephoneNamesAndProcesses/README_RU.md @@ -39,7 +39,7 @@ "Процесс" -- любой кусок кода на ро. Например, наша игра в сломанный телефон или пиццерия из предыдущих уроков. Процессы могуть быть программами на сотни строк или кусочками на одну строчку. Они даже могут быть крошечными фрагментами кода, которые представляют собой значения. Вот примеры процессов: - - `stdout!("Sup Rholang?")` Обычная отправка + - `result!("Sup Rholang?")` Обычная отправка - `Nil` Наименьший возможный процесс. Он буквально значит "ничего не делать". - `for(msg <- @"phone"){Nil}` Обычное получение, которые ничего не делает, когда поступает сообщение. - `"Hello World"` Ещё один маленький процесс, который ничего не делает. Такие процессы называются "базовыми выражениями" ("Ground Terms"). @@ -120,7 +120,7 @@ What is `@Nil`? - [ ] `@"BobsPhone"` - [ ] `*"BobsPhone"` - [ ] `@*BobsPhone` -- [ ] `stdout!("BobsPhone")` +- [ ] `result!("BobsPhone")` diff --git a/03-TelephoneNamesAndProcesses/telephone3.rho b/03-TelephoneNamesAndProcesses/telephone3.rho index 56f9584..35cfb57 100644 --- a/03-TelephoneNamesAndProcesses/telephone3.rho +++ b/03-TelephoneNamesAndProcesses/telephone3.rho @@ -1,4 +1,4 @@ -new alice, bob, stdout(`rho:io:stdout`) in { +new result, alice, bob in { // Start the game by sending a message to Alice alice!("How to program: Change stuff and see what happens.") | @@ -14,6 +14,6 @@ new alice, bob, stdout(`rho:io:stdout`) in { // Concurrently, Bob will listens for the message for (message <- bob) { // Bob is the last player, so he'll announce the message - stdout!(*message) + result!(*message) } } diff --git a/04-PersistentSendAndPeek/README.md b/04-PersistentSendAndPeek/README.md index cbb1424..dd99bf8 100644 --- a/04-PersistentSendAndPeek/README.md +++ b/04-PersistentSendAndPeek/README.md @@ -21,7 +21,7 @@ Confirm for yourself that the original send is still in the tuplespace. ### Exercise Modify the above code so that a second pilot also receives the information. Still, the send persists. -By the way, did you notice that we don't need `new stdout(...) in {}` when we don't actually print anything to the screen `stdout`? +By the way, did you notice that we don't need `new result(...) in {}` when we don't actually print anything to the screen `result`? How many comm events happen in `for (x <- y) {Nil} | y!!(Nil)` - [x] `1` @@ -55,13 +55,13 @@ One problem with the code above is that a forgetful pilot may not actually put t ![Peeking at a message allows you to read it without consuming it.](letterPeek.png) -Rholang will have a special syntax for this sort of thing eventually. It isn't available right now, but I'll show you the syntax just so you're ready. To "peek" at what's on a channel without consuming it, use the ` -大多数程序语言都允许你组合或者"串联"两个字符串在一起,当然Rholang也不例外了。我们可以 `stdout!("Hello " ++ "world")`, 但是我们不能串联一个字符串和一个整型。那就是为什么我们要用`stdoutAck`这个方法。另一个方法就是打印一个列表 `stdout!(["Bill caught it. Points earned: ", *points])`。我们将在未来课程讨论更多关于这方面的细节。 +大多数程序语言都允许你组合或者"串联"两个字符串在一起,当然Rholang也不例外了。我们可以 `result!("Hello " ++ "world")`, 但是我们不能串联一个字符串和一个整型。那就是为什么我们要用`stdoutAck`这个方法。另一个方法就是打印一个列表 `stdout!(["Bill caught it. Points earned: ", *points])`。我们将在未来课程讨论更多关于这方面的细节。 在rholang里的这个游戏与现实中一个球不断重复抛有什么区别? - [ ] 是相当准确的模拟 diff --git a/07-BundlesAndInterpolation/fanmailAsk.rho b/07-BundlesAndInterpolation/fanmailAsk.rho index fc5a90f..065e64d 100644 --- a/07-BundlesAndInterpolation/fanmailAsk.rho +++ b/07-BundlesAndInterpolation/fanmailAsk.rho @@ -1,4 +1,4 @@ -new alice, bob, eve, stdout(`rho:io:stdout`) in { +new result, alice, bob, eve in { // Alice get a lot of fan mail, so she // creates a new write only bundle and publishes it. @@ -12,7 +12,7 @@ new alice, bob, eve, stdout(`rho:io:stdout`) in { // Alice also reads fan mail for (mail <- aliceFanMail) { - stdout!("Alice received a fanmail") + result!("Alice received a fanmail") } } | @@ -33,7 +33,7 @@ new alice, bob, eve, stdout(`rho:io:stdout`) in { alice!(*return) | for (aliceFanMail <- return) { for (@stolenMail <= aliceFanMail) { - stdout!(["Eve stole a message: ", stolenMail]) + result!(["Eve stole a message: ", stolenMail]) } } } diff --git a/07-BundlesAndInterpolation/fanmailBad.rho b/07-BundlesAndInterpolation/fanmailBad.rho index 180bff7..4fc386e 100644 --- a/07-BundlesAndInterpolation/fanmailBad.rho +++ b/07-BundlesAndInterpolation/fanmailBad.rho @@ -1,7 +1,7 @@ -new alice, stdout(`rho:io:stdout`) in { +new result, alice in { // Alice reads fan mail for (mail <- alice) { - stdout!("Alice received a fanmail") + result!("Alice received a fanmail") } | diff --git a/07-BundlesAndInterpolation/fanmailEve.rho b/07-BundlesAndInterpolation/fanmailEve.rho index 6d5ff55..9333d7c 100644 --- a/07-BundlesAndInterpolation/fanmailEve.rho +++ b/07-BundlesAndInterpolation/fanmailEve.rho @@ -1,3 +1,3 @@ for (@stolenMail <= alice) { - stdout!("Eve stole a message") + result!("Eve stole a message") } diff --git a/07-BundlesAndInterpolation/fanmailPublish.rho b/07-BundlesAndInterpolation/fanmailPublish.rho index 933090f..779fb4d 100644 --- a/07-BundlesAndInterpolation/fanmailPublish.rho +++ b/07-BundlesAndInterpolation/fanmailPublish.rho @@ -1,4 +1,4 @@ -new alice, bob, eve, stdout(`rho:io:stdout`) in { +new result, alice, bob, eve in { // Alice gets a lot of fan mail, so she // creates a new write only bundle and publishes it. @@ -10,7 +10,7 @@ new alice, bob, eve, stdout(`rho:io:stdout`) in { // Alice also reads fan mail for (mail <= aliceFanMail) { - stdout!("Alice received a fanmail") + result!("Alice received a fanmail") } } | @@ -26,7 +26,7 @@ new alice, bob, eve, stdout(`rho:io:stdout`) in { // because Alice's fanmail channel is write-only for (aliceFanMail <- alice) { for (@stolenMail <= aliceFanMail) { - stdout!(["Eve stole a message: ", stolenMail]) + result!(["Eve stole a message: ", stolenMail]) } } } diff --git a/07-BundlesAndInterpolation/interpolation.rho b/07-BundlesAndInterpolation/interpolation.rho index 2a45e3b..57c8529 100644 --- a/07-BundlesAndInterpolation/interpolation.rho +++ b/07-BundlesAndInterpolation/interpolation.rho @@ -1,8 +1,7 @@ -new stdout(`rho:io:stdout`), printStuff in { - +new result in { printStuff!({"noun": "person", "adverb": "sideways"}) | contract printStuff(map) = { - stdout!("The ${noun} jumped ${adverb}" %% *map) + result!("The ${noun} jumped ${adverb}" %% *map) } } diff --git a/07-BundlesAndInterpolation/jackPotNicePrinting.rho b/07-BundlesAndInterpolation/jackPotNicePrinting.rho index 4d2ccab..0e7f47b 100644 --- a/07-BundlesAndInterpolation/jackPotNicePrinting.rho +++ b/07-BundlesAndInterpolation/jackPotNicePrinting.rho @@ -3,7 +3,7 @@ for (points <= @throw){ stdoutAck!("Bill caught it. Points earned: ", *ack) | for( _ <- ack){ - stdout!(*points) + result!(*points) } } } diff --git a/07-BundlesAndInterpolation/jackpot.rho b/07-BundlesAndInterpolation/jackpot.rho index cf0023f..1321e2f 100644 --- a/07-BundlesAndInterpolation/jackpot.rho +++ b/07-BundlesAndInterpolation/jackpot.rho @@ -1,4 +1,4 @@ -new throw, stdout(`rho:io:stdout`) in { +new result, throw in { // Throw the ball worth five points throw!(5) | @@ -10,10 +10,10 @@ new throw, stdout(`rho:io:stdout`) in { // Bill and Paige both try to catch for (points <= throw){ - stdout!("Bill caught it") + result!("Bill caught it") } | for (points <= throw){ - stdout!("Paige caught it") + result!("Paige caught it") } } diff --git a/07-BundlesAndInterpolation/jackpotPublish.rho b/07-BundlesAndInterpolation/jackpotPublish.rho index a240893..2eff570 100644 --- a/07-BundlesAndInterpolation/jackpotPublish.rho +++ b/07-BundlesAndInterpolation/jackpotPublish.rho @@ -1,4 +1,4 @@ -new gameCh, stdout(`rho:io:stdout`) in { +new result, gameCh in { new throw in { //Give out read-only access @@ -13,7 +13,7 @@ new gameCh, stdout(`rho:io:stdout`) in { // Bill and Paige join the game for (throw <- gameCh){ for (points <= throw){ - stdout!(["Bill caught it. Points: ", *points]) + result!(["Bill caught it. Points: ", *points]) } } | diff --git a/08-StateChannelsAndMethods/box.rho b/08-StateChannelsAndMethods/box.rho index c6321db..a68f972 100644 --- a/08-StateChannelsAndMethods/box.rho +++ b/08-StateChannelsAndMethods/box.rho @@ -1,4 +1,4 @@ -new stdout(`rho:io:stdout`), boxCh in { +new result, boxCh in { // To save data we just put it in the box boxCh!(42) | @@ -6,6 +6,6 @@ new stdout(`rho:io:stdout`), boxCh in { // Then to get data back out for (data <- boxCh) { // Do whatever you want with the data here. - stdout!(*data) + result!(*data) } } diff --git a/08-StateChannelsAndMethods/counter.rho b/08-StateChannelsAndMethods/counter.rho index c08a379..265af70 100644 --- a/08-StateChannelsAndMethods/counter.rho +++ b/08-StateChannelsAndMethods/counter.rho @@ -1,4 +1,4 @@ -new currentCount, increase, reset, check, stdout(`rho:io:stdout`) in { +new result, currentCount, increase, reset, check in { // Starting the counter at 0 currentCount!(0) | @@ -32,7 +32,7 @@ new currentCount, increase, reset, check, stdout(`rho:io:stdout`) in { // And check it's value afterwards for(_ <- ack; count <- currentCount) { - stdout!(*count) + result!(*count) } } } diff --git a/08-StateChannelsAndMethods/counterFactory.rho b/08-StateChannelsAndMethods/counterFactory.rho index c34414e..889f163 100644 --- a/08-StateChannelsAndMethods/counterFactory.rho +++ b/08-StateChannelsAndMethods/counterFactory.rho @@ -1,4 +1,4 @@ -new counterFactory, stdout(`rho:io:stdout`) in { +new result, counterFactory in { contract counterFactory(increase, reset) = { new currentCount in { // Start the counter at zero diff --git a/08-StateChannelsAndMethods/counterTests.rho b/08-StateChannelsAndMethods/counterTests.rho index b21fb60..d0d41c1 100644 --- a/08-StateChannelsAndMethods/counterTests.rho +++ b/08-StateChannelsAndMethods/counterTests.rho @@ -1,4 +1,4 @@ -new ack in { +new result, ack in { // This gets deeply nested because it's sequential. // This indentation style keeps it readable increase!(*ack) | for(_ <- ack) { @@ -14,7 +14,7 @@ new ack in { reset!(*ack) | for(count <- ack) { check!(*ack) | for(count <- ack) { - stdout!(*count) + result!(*count) }}}}}}}} } diff --git a/08-StateChannelsAndMethods/patience.rho b/08-StateChannelsAndMethods/patience.rho index 408c407..8abf929 100644 --- a/08-StateChannelsAndMethods/patience.rho +++ b/08-StateChannelsAndMethods/patience.rho @@ -1,4 +1,4 @@ -new P1, P2, stdout(`rho:io:stdout`) in { +new result, P1, P2 in { // active gets its own scope so players can't change its value. new active in { @@ -6,13 +6,13 @@ new P1, P2, stdout(`rho:io:stdout`) in { | for(_ <- active; _ <- P1) { for( _ <- P2) { - stdout!("P2 Wins") + result!("P2 Wins") } } | for(_ <- active; _ <- P2) { for (_ <- P1) { - stdout!("P1 Wins") + result!("P1 Wins") } } } diff --git a/09-ObjectCapabilities/atc.rho b/09-ObjectCapabilities/atc.rho index 531fc99..45592d6 100644 --- a/09-ObjectCapabilities/atc.rho +++ b/09-ObjectCapabilities/atc.rho @@ -1,5 +1,5 @@ -new stationFactory, stdout(`rho:io:stdout`) in { +new result, stationFactory in { contract stationFactory(initialMessage, getInfo, setInfo) = { new currentMessage in { // Populate the initial message @@ -33,5 +33,5 @@ new stationFactory, stdout(`rho:io:stdout`) in { } | // Listener tunes in to receive latest message - airportInfo!(*stdout) + airportInfo!(*result) } diff --git a/10-MoreSyntax/README.md b/10-MoreSyntax/README.md index 1e04876..e08bd2c 100644 --- a/10-MoreSyntax/README.md +++ b/10-MoreSyntax/README.md @@ -14,7 +14,7 @@ The final binary operator you should know is `++` which is used for "concatenati [greeter.rho](greeter.rho) -What would the code `stdout!("I" ++ "<3" ++ "rholang")` output? +What would the code `result!("I" ++ "<3" ++ "rholang")` output? - [ ] I <3 rholang - [ ] ["I", "<3", "rholang"] - [x] I<3rholang @@ -47,7 +47,7 @@ What code could be parred with the previous code to leave the number `24` on `do ### Exercise Revisit the telephone game from lesson 3 and show that we could have used the `@message` pattern so `message` would be a process. -What should replace the ... in `for(@x <- @y){stdout!(...)}` to make the program valid? +What should replace the ... in `for(@x <- @y){result!(...)}` to make the program valid? - [ ] `@x` - [x] `x` - [ ] `*x` @@ -101,17 +101,17 @@ Rholang also has the classic Boolean operators AND, OR, and NOT. The syntax is * `a or b` true when either `a` or `b` is true * `not a` true when `a` is false -What would `stdout!(true and true)` output? +What would `result!(true and true)` output? - [x] true - [ ] false - [ ] neither; that's invalid syntax -What would `stdout!(not true)` output? +What would `result!(not true)` output? - [ ] true - [x] false - [ ] neither; that's invalid syntax -What would `stdout!((not not true) or false)` output? +What would `result!((not not true) or false)` output? - [x] true - [ ] false - [ ] neither; that's invalid syntax diff --git a/10-MoreSyntax/README_CN.md b/10-MoreSyntax/README_CN.md index 0dbefe3..b14def7 100644 --- a/10-MoreSyntax/README_CN.md +++ b/10-MoreSyntax/README_CN.md @@ -14,7 +14,7 @@ [greeter.rho](greeter.rho) -代码 `stdout!("I" ++ "<3" ++ "rholang")` 会输出什么? +代码 `result!("I" ++ "<3" ++ "rholang")` 会输出什么? - [ ] I <3 rholang - [ ] ["I", "<3", "rholang"] - [x] I<3rholang @@ -47,7 +47,7 @@ ### 练习 重看一下第三课中传音筒的游戏,那个展示我们已经使用了`@message`的语法模式,所以`message`是一个"process" -我们应该把 `for(@x <- @y){stdout!(...)}` 中 ... 替换为什么来让程序是正确的? +我们应该把 `for(@x <- @y){result!(...)}` 中 ... 替换为什么来让程序是正确的? - [ ] `@x` - [x] `x` - [ ] `*x` @@ -103,17 +103,17 @@ Rholang也有传统的布尔操作符, AND, OR, 和 NOT。语法是 * 当 `a`是假的 ,`not a` 是真的 -`stdout!(true and true)` 会输出什么?? +`result!(true and true)` 会输出什么?? - [x] true - [ ] false - [ ] 都不是; 非法语法 -`stdout!(not true)` 会输出什么? +`result!(not true)` 会输出什么? - [ ] true - [x] false - [ ] 都不是; 非法语法 -`stdout!((not not true) or false)` 会输出什么? +`result!((not not true) or false)` 会输出什么? - [x] true - [ ] false - [ ] 都不是; 非法语法 diff --git a/10-MoreSyntax/greeter.rho b/10-MoreSyntax/greeter.rho index 8ed7f36..264f90d 100644 --- a/10-MoreSyntax/greeter.rho +++ b/10-MoreSyntax/greeter.rho @@ -1,10 +1,10 @@ -new greeter in { +new result, greeter in { contract greeter(name, return) = { return!("Hello there, " ++ *name) } | - new stdout(`rho:io:stdout`) in { - greeter!("Joshy", *stdout)| - greeter!("Tom", *stdout) + new result in { + greeter!("Joshy", *result)| + greeter!("Tom", *result) } } diff --git a/10-MoreSyntax/math.rho b/10-MoreSyntax/math.rho index aa9adf2..226d397 100644 --- a/10-MoreSyntax/math.rho +++ b/10-MoreSyntax/math.rho @@ -1,4 +1,4 @@ -new c2f, f2c in { +new result, c2f, f2c in { /** * Converts Celcius temperatures to Farenheit. The conversion @@ -14,11 +14,9 @@ new c2f, f2c in { } | - new stdout(`rho:io:stdout`) in { // 0 C should be 32 F - c2f!(0, *stdout) + c2f!(0, *result) | // 100 C should be 212 F - c2f!(100, *stdout) - } + c2f!(100, *result) } diff --git a/10-MoreSyntax/signTest.rho b/10-MoreSyntax/signTest.rho index c4902be..6c03e40 100644 --- a/10-MoreSyntax/signTest.rho +++ b/10-MoreSyntax/signTest.rho @@ -1,9 +1,9 @@ -new stdout(`rho:io:stdout`) in { +new result in { for (@balance <= @"signTest") { if (balance > 0) { - stdout!("Account in good standing.") + result!("Account in good standing.") } else { - stdout!("Account overdrawn.") + result!("Account overdrawn.") } } } diff --git a/11-PatternMatching/README.md b/11-PatternMatching/README.md index 1f7d6c3..0da7f92 100644 --- a/11-PatternMatching/README.md +++ b/11-PatternMatching/README.md @@ -93,7 +93,7 @@ To match both of two patterns you use the "intersection" operator, `/\`. In this [intersection.rho](intersection.rho) -Notice I called my stdout channel `print` that time. You can call those names anything you'd like. Although it's generally good to be consistent so as not to confuse anyone. From here on I'll stick with `stdout`. +Notice I called my result channel `print` that time. You can call those names anything you'd like. Although it's generally good to be consistent so as not to confuse anyone. From here on I'll stick with `result`. ### Exercise The union example here is pretty basic. Expand it so it can match more languages and more words. Also write tests that show what happens when only the default pattern is matched. diff --git a/11-PatternMatching/greeter2.rho b/11-PatternMatching/greeter2.rho index 5c514f5..4b81d17 100644 --- a/11-PatternMatching/greeter2.rho +++ b/11-PatternMatching/greeter2.rho @@ -1,5 +1,5 @@ -new greeter in { +new result, greeter in { contract greeter(name, return) = { return!("Hello there, " ++ *name) } @@ -9,8 +9,6 @@ new greeter in { return!("Hello there, world") } | - new stdout(`rho:io:stdout`) in { - greeter!("Joshy", *stdout)| - greeter!("Tom", *stdout) - } + greeter!("Joshy", *result)| + greeter!("Tom", *result) } diff --git a/11-PatternMatching/intersection.rho b/11-PatternMatching/intersection.rho index 80daaee..c6ebf9b 100644 --- a/11-PatternMatching/intersection.rho +++ b/11-PatternMatching/intersection.rho @@ -1,4 +1,4 @@ -new print(`rho:io:stdout`), register in { +new print, register in { for (@{{@"name"!(_) | _} /\ {@"age"!(_) | _}} <= register){ print!("Both name and age were in the data") diff --git a/11-PatternMatching/matching.rho b/11-PatternMatching/matching.rho index 4d54959..92ea49f 100644 --- a/11-PatternMatching/matching.rho +++ b/11-PatternMatching/matching.rho @@ -1,12 +1,12 @@ -new patternMatcher, stdout(`rho:io:stdout`) in { +new result, patternMatcher in { for (x <= patternMatcher) { match *x { - Nil => stdout!("Got the stopped process") - "hello" => stdout!("Got the string hello") - [x, y] => stdout!("Got a two-element list") - Int => stdout!("Got an integer") - _ => stdout!("Got something else") + Nil => result!("Got the stopped process") + "hello" => result!("Got the string hello") + [x, y] => result!("Got a two-element list") + Int => result!("Got an integer") + _ => result!("Got something else") } } | diff --git a/11-PatternMatching/missileSafe.rho b/11-PatternMatching/missileSafe.rho index a9d2553..2321d81 100644 --- a/11-PatternMatching/missileSafe.rho +++ b/11-PatternMatching/missileSafe.rho @@ -1,4 +1,4 @@ -new getInspectionChannel, log(`rho:io:stdout`), missile in { +new log, getInspectionChannel, missile in { contract @(*missile, "launch")(_) = { log!("launching...") diff --git a/11-PatternMatching/missileUnsafe.rho b/11-PatternMatching/missileUnsafe.rho index 4d44bc5..d583e64 100644 --- a/11-PatternMatching/missileUnsafe.rho +++ b/11-PatternMatching/missileUnsafe.rho @@ -1,4 +1,4 @@ -new log(`rho:io:stdout`), missile in { +new log, missile in { contract @(*missile, "launch")(_) = { log!("launching...") diff --git a/11-PatternMatching/sendASend.rho b/11-PatternMatching/sendASend.rho index e348d59..63d4c83 100644 --- a/11-PatternMatching/sendASend.rho +++ b/11-PatternMatching/sendASend.rho @@ -1,11 +1,11 @@ -new patternMatcher, stdout(`rho:io:stdout`) in { +new result, patternMatcher in { for (x <= patternMatcher) { match *x { - Nil => stdout!("Got the stopped process") - {_!(_)} => stdout!("Got a send") - {for(@0 <- _){_}} => stdout!("Got a receive on @0") - _ => stdout!("Got something else") + Nil => result!("Got the stopped process") + {_!(_)} => result!("Got a send") + {for(@0 <- _){_}} => result!("Got a receive on @0") + _ => result!("Got something else") } } | diff --git a/11-PatternMatching/union.rho b/11-PatternMatching/union.rho index 7b289cb..8dde628 100644 --- a/11-PatternMatching/union.rho +++ b/11-PatternMatching/union.rho @@ -1,4 +1,4 @@ -new log(`rho:io:stdout`), binderChecker in { +new log, binderChecker in { contract binderChecker(@data, return) = { match data { "nombre" \/ "name" => return!("name-like") diff --git a/12-DataStructures/README.md b/12-DataStructures/README.md index da96aa2..a6c7f97 100644 --- a/12-DataStructures/README.md +++ b/12-DataStructures/README.md @@ -144,13 +144,13 @@ We've learned about several interesting data structures in this lesson. Data str In this example, Alice and Bob each have one unforgeable name (that I've called key). The keys may be useful on their own (for things not shown in the snippet), but only when used together, can the contract shown be called. This is known as "rights amplification". ``` -new alice, bob, key1, key2, stdout(`rho:io:stdout`) in { +new result, alice, bob, key1, key2 in { alice!(*key1)| bob!(*key2)| contract @(*key1, *key2)(_) = { - stdout!("Congratulations, Alice and Bob, you've cooperated.") + result!("Congratulations, Alice and Bob, you've cooperated.") } } ``` diff --git a/12-DataStructures/capitalOf.rho b/12-DataStructures/capitalOf.rho index 94ffb5b..817c448 100644 --- a/12-DataStructures/capitalOf.rho +++ b/12-DataStructures/capitalOf.rho @@ -1,4 +1,4 @@ -new capitalOf, print(`rho:io:stdout`) in { +new print, capitalOf in { new mapCh in { // Use a persistent send instead of peeking later diff --git a/12-DataStructures/list.rho b/12-DataStructures/list.rho index 8def1ad..3174b91 100644 --- a/12-DataStructures/list.rho +++ b/12-DataStructures/list.rho @@ -1,28 +1,28 @@ -new lCh, stdout(`rho:io:stdout`) in { +new result, lCh in { // Make a new list, l lCh!!([3, 4, 5])| // Test nth for (@l <- lCh){ - stdout!("Test nth. Expected: 5. Got: ${ans}" %% {"ans": l.nth(2)}) + result!("Test nth. Expected: 5. Got: ${ans}" %% {"ans": l.nth(2)}) } | // Test toByteArray for (@l <- lCh){ - stdout!(["Test toByteArray. Got: ", l.toByteArray()]) + result!(["Test toByteArray. Got: ", l.toByteArray()]) } | // Test slice for (@l <- lCh){ - stdout!(["Test slice. Expected: [4, 5]. Got: ", l.slice(1, 3)]) + result!(["Test slice. Expected: [4, 5]. Got: ", l.slice(1, 3)]) } | // Test length for (@l <- lCh){ - stdout!("Test length. Expected: 3. Got: '${ans}" %% {"ans": l.length()}) + result!("Test length. Expected: 3. Got: '${ans}" %% {"ans": l.length()}) } } diff --git a/12-DataStructures/map.rho b/12-DataStructures/map.rho index 72e5045..6d9a598 100644 --- a/12-DataStructures/map.rho +++ b/12-DataStructures/map.rho @@ -1,4 +1,4 @@ -new mCh, print(`rho:io:stdout`) in { +new print, mCh in { mCh!!({"a": 3, "b": 4, "c": 5})| diff --git a/12-DataStructures/set.rho b/12-DataStructures/set.rho index d066b44..af53cb1 100644 --- a/12-DataStructures/set.rho +++ b/12-DataStructures/set.rho @@ -1,46 +1,46 @@ -new sCh, stdout(`rho:io:stdout`) in { +new result, sCh in { sCh!!(Set(3, 4, 5))| // Test toByteArray for (@s <- sCh){ - stdout!(["Test toByteArray. Got: ", s.toByteArray()]) + result!(["Test toByteArray. Got: ", s.toByteArray()]) } | // Test Add for (@s <- sCh){ - stdout!(["Test add. Expected Set(3, 4, 5, 6), Got: ", s.add(6)]) + result!(["Test add. Expected Set(3, 4, 5, 6), Got: ", s.add(6)]) } | // Test Diff for (@s <- sCh){ - stdout!(["Test diff. Expected: Set(5) Got: ", s.diff(Set(3, 4))]) + result!(["Test diff. Expected: Set(5) Got: ", s.diff(Set(3, 4))]) } | // Test Union for (@s <- sCh){ - stdout!(["Test union. Expected: Set(1, 2, 3, 4, 5). Got: ", s.union(Set(1, 2))]) + result!(["Test union. Expected: Set(1, 2, 3, 4, 5). Got: ", s.union(Set(1, 2))]) } | // Test Delete for (@s <- sCh){ - stdout!(["Test delete. Expected: Set(3, 4). Got: ", s.delete(5)]) + result!(["Test delete. Expected: Set(3, 4). Got: ", s.delete(5)]) } | // Test Contains for (@s <- sCh){ - stdout!(["Test contains. Expected: true. Got:", s.contains(5)])| - stdout!(["Test contains. Expected: false. Got: ", s.contains(6)]) + result!(["Test contains. Expected: true. Got:", s.contains(5)])| + result!(["Test contains. Expected: false. Got: ", s.contains(6)]) } | // Test Size for (@s <- sCh){ - stdout!("Test size. Expected 3. Got: ${ans}" %% {"ans": s.size()}) + result!("Test size. Expected 3. Got: ${ans}" %% {"ans": s.size()}) } } diff --git a/12-DataStructures/tuple.rho b/12-DataStructures/tuple.rho index 37bfca6..d8e1204 100644 --- a/12-DataStructures/tuple.rho +++ b/12-DataStructures/tuple.rho @@ -1,4 +1,4 @@ -new tCh, print(`rho:io:stdout`) in { +new print, tCh in { tCh!!((3, 4, 5))| diff --git a/12-DataStructures/wordLength.rho b/12-DataStructures/wordLength.rho index 499a299..79a9989 100644 --- a/12-DataStructures/wordLength.rho +++ b/12-DataStructures/wordLength.rho @@ -1,8 +1,8 @@ -new wordLength, stdout(`rho:io:stdout`) in { +new result, wordLength in { contract wordLength(@word) = { - stdout!("How many characters in " ++ word)| - stdout!(word.length())| - stdout!("Shorter version: " ++ word.slice(0, 5)) + result!("How many characters in " ++ word)| + result!(word.length())| + result!("Shorter version: " ++ word.slice(0, 5)) } | wordLength!("Cantaloupe") diff --git a/15-GoingOffChain/insertArbitrary.rho b/15-GoingOffChain/insertArbitrary.rho index 178c16b..eb547a2 100644 --- a/15-GoingOffChain/insertArbitrary.rho +++ b/15-GoingOffChain/insertArbitrary.rho @@ -1,7 +1,7 @@ -new doubler, +new result, doubler, uriChan, - insertArbitrary(`rho:registry:insertArbitrary`), - stdout(`rho:io:stdout`) in { + insertArbitrary(`rho:registry:insertArbitrary`) + in { // This is a silly contract that we'll register contract doubler(@n /\ Int, return) = { @@ -14,6 +14,6 @@ new doubler, // Wait for URI response for(@uri <- uriChan) { - stdout!(uri) + result!(uri) } } diff --git a/15-GoingOffChain/lookup.rho b/15-GoingOffChain/lookup.rho index a723e10..8d1163e 100644 --- a/15-GoingOffChain/lookup.rho +++ b/15-GoingOffChain/lookup.rho @@ -1,6 +1,5 @@ -new doublerCh, - lookup(`rho:registry:lookup`), - stdout(`rho:io:stdout`) in { +new result, doublerCh, + lookup(`rho:registry:lookup`) in { // Ask the registry to lookup the URI and send the contract back on doublerCh lookup!(`rho:id:fos1m8yaki3s8g1ytzkr6boucnhab6nafoco8ww63xqj5k8aa1xfza`, *doublerCh) | @@ -8,7 +7,7 @@ new doublerCh, // Wait to receive the answer back from the registry for( doubler <- doublerCh) { - // Double a number and send the answer to stdout - doubler!(7, *stdout) + // Double a number and send the answer to result + doubler!(7, *result) } } diff --git a/converter/README.md b/converter/README.md index 85665bf..f5ea5f3 100644 --- a/converter/README.md +++ b/converter/README.md @@ -7,3 +7,16 @@ run node ../converter/index.js index.md The output is in ./index.html https://marked.js.org/#/USING_PRO.md + + +``` +git clone https://github.com/rchain-community/LearnRholangByExample +cd LearnRholangByExample +npm install +npm install marked +node converter/index.js README.md +for d in */.; do cd $d;ls *.md| while read f; do node ../converter/index.js $f; done; cd ..; done +find . -name README.html |while read f; do cp -p $f $(echo $f|sed 's/README/index/');done +cd .. +rm -r node-modules +scp -r LearnRholangByExample rchain@rhobot.net:/var/www/html diff --git a/converter/package-lock.json b/converter/package-lock.json index a2a99ec..546c9d6 100644 --- a/converter/package-lock.json +++ b/converter/package-lock.json @@ -10,6 +10,7 @@ "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" }, "marked": { + "version": "0.6.1", "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.1.tgz", "integrity": "sha512-+H0L3ibcWhAZE02SKMqmvYsErLo4EAVJxu5h3bHBBDvvjeWXtl92rGUSBYHL2++5Y+RSNgl8dYOAXcYe7lp1fA==" diff --git a/converter/package.json b/converter/package.json index 269a496..43cf6de 100644 --- a/converter/package.json +++ b/converter/package.json @@ -17,6 +17,7 @@ "license": "ISC", "dependencies": { "fs": "0.0.1-security", + "marked": "^0.6.1" } }