statements change the environment, expressions do not
do-nothing statement を定義
- 簡約した結果を再び代入
- Environmentは変化しない
| defmodule Loop do | |
| def each([head|tail], fun) do | |
| [fun.(head)|each(tail, fun)] | |
| end | |
| def each([], _) do | |
| [] | |
| end | |
| end | |
| Loop.each [1, 2], fn element -> |
| [254, 253, 3].map { |v| v.to_s(16).rjust(2, '0') }.join |
| #include <iostream> | |
| #include <stdint.h> | |
| class Area; | |
| class Quest; | |
| template <typename T, typename Meaning> | |
| struct Explicit | |
| { | |
| Explicit() {} |
| double throwDice() { | |
| std::random_device rd; | |
| std::mt19937 gen(rd()); | |
| std::uniform_real_distribution<> dis(0, 1); | |
| return dis(gen); | |
| } | |
| template<class T> | |
| typename std::vector<T>::const_iterator lottery( | |
| const std::vector<T>& list, |
| *.cpp filter=cpplint_cleaner | |
| *.h filter=cpplint_cleaner |
| class SomeClass{ | |
| public: | |
| virtual void func() { | |
| std::cout << "SomeClass::func called" << std::endl; | |
| } | |
| }; | |
| class SubOfSomeClass : public SomeClass { | |
| public: | |
| virtual void func() override { |
| #include <iostream> | |
| #include <unistd.h> | |
| class bar{ | |
| public: | |
| bar(){} | |
| ~bar(){} | |
| void setPointer(void* pointer){ | |
| std::cout << "setPointer called" << std::endl; | |
| _pointer = pointer; |
| #include <iostream> | |
| class Super{ | |
| public: | |
| virtual void func(){ | |
| std::cout << "super" << std::endl; | |
| } | |
| virtual Super* someFunc(){ | |
| std::cout << "Super::someFunc()" << std::endl; |
| #include "dist/json/json.h" | |
| int main(void){ | |
| Json::Reader reader; | |
| Json::Value rootJson; | |
| bool parseResult = reader.parse(" \ | |
| \"areas\" : [ \ | |
| {\ | |
| \"background_image\" : \"background_cave\",\ | |
| \"description\" : \"desc\",\ |