module Aの機能をmodule Bから利用する.ある機能を特定の使い方で特殊化させたsubsetを追加したいとき,そのsubsetをどの段階で実装するか.
呼びだす側Bで実装する.
メリット
- 呼びだされるAは最小限の記述.
デメリット
- Aを用いるmoduleが多いと呼び出し先のそのmodule同士で重複するコードが増える.
| string expandenv(string str) | |
| { | |
| string result = str; | |
| string prev = ""; | |
| cont = 1; | |
| while(cont){ | |
| prev = result; | |
| result = execute("echo " + "`" + result + "`"); | |
| cont = strcmp(prev, result) != 0; | |
| } |
| import hou | |
| import sys | |
| def transfer_transform(): | |
| source = hou.selectedNodes()[0] | |
| if source is None: return | |
| target = hou.selectedNodes()[1] | |
| if target is None: return | |
| tx = source.parm("tx").eval() | |
| ty = source.parm("ty").eval() |
| import hou | |
| source = hou.selectedNodes()[0] | |
| target = hou.selectedNodes()[1] | |
| elm_list = [] | |
| for point in source.geometry().points(): | |
| pos = point.floatListAttribValue('P') | |
| elm_list.append(','.join(map(lambda v: str(v), pos))) | |
| elm_list_str = ' '.join(elm_list) |
| module syncbox; | |
| import rx; | |
| /// | |
| struct SyncableObserver{ | |
| public{ | |
| void put(Event n){} | |
| // void put(int n){} : linker error | |
| }//public | |
| }//struct SyncableObserver |
| #Clone llvm | |
| git clone http://llvm.org/git/llvm.git | |
| #Clone clang | |
| cd llvm/tools/ | |
| git clone http://llvm.org/git/clang.git | |
| #Clone clang-Tools-Extra | |
| cd clang/tools | |
| git clone http://llvm.org/git/clang-tools-extra.git extra |
| lerp( | |
| lerp( | |
| lerp( | |
| grad (aaa, xf , yf , zf), // The gradient function calculates the dot product between a pseudorandom | |
| grad (baa, xf-1, yf , zf), // gradient vector and the vector from the input coordinate to the 8 | |
| u | |
| ), | |
| lerp( | |
| grad (aba, xf , yf-1, zf), // This is all then lerped together as a sort of weighted average based on the faded (u,v,w) | |
| grad (bba, xf-1, yf-1, zf), // values we made earlier. |
| void setAttribute(Args ...)(string location, Args args){ | |
| if(_isLoaded){ | |
| static if(Args.length == 1){ | |
| static if(is( Args == double[] )){ | |
| glVertexAttrib1d(location, v[0]); | |
| }else if(is(Args == float[])){ | |
| glVertexAttrib1f(location, v[0]); | |
| }else if(is( Args == ar.Vector!(double, 2) )){ | |
| glVertexAttrib2d(location, v[0], v[1]); | |
| }else if(is(Args == ar.Vector!(float, 2))){ |
| import armos; | |
| import std.stdio; | |
| class Hoge{ | |
| void func(void delegate() f){ | |
| f(); | |
| } | |
| } | |
| class TestApp : ar.BaseApp{ | |
| auto hoge = new Hoge; | |
| void mouseMoved(int x, int y, int button){ |
| class Moge{}; | |
| class Hoge { | |
| public: | |
| Moge moge; | |
| Moge constFunc()const{ | |
| return moge; | |
| } | |
| }; | |
| int main(){ | |
| Hoge obj; |