- これは Zig ドキュメント 0.10.0 を DeepL Pro を利用して翻訳したものです。
- 自分用に翻訳しています
- そのうち GitHub リポジトリ管理に切り替えます
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| # copied from http://goran.krampe.se/2014/12/03/nim-seq/ | |
| # Dollars and Kgs | |
| type | |
| Dollar* = distinct float | |
| Kg* = distinct float | |
| proc `$`*(x: Dollar) :string = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| let argc = paramCount() | |
| # プログラム名以外(C言語等におけるargv[1]以降) | |
| let argv = commandLineParams() | |
| # プログラム名のフルパス(C言語等におけるargv[0]) | |
| let programName = getAppFilename() |
もともとは、DLLをオープンしてシンボル参照して、必要な関数を呼ぶ形式にすれば、簡単にmruby-webcam (OpenCVの力を借りてWebCamの画像を表示する)のマルチプラットフォーム対応のバイナリが作成出来ると考えていた。
しかし、OpenCVは32ビット環境では最新版ではWebCamが扱えない状態C++ APIを使う必要がある
さらに悪いことc++はdlopenやLoadLibraryではマングリング問題やnewやdeleteのラッパーが必要で簡単には使えない。 JulialangでC++の関数の呼び出しがサポートされていることを知るも、これも、完全なものではなく、せいぜい マングリングを解決する程度のものであった。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # これはコメントである | |
| echo "お名前は? " | |
| var name: string = readLine(stdin) | |
| echo "やあ、", name, "!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| type | |
| TUtf16Char = distinct int16 | |
| WideCString = ptr array[0.. 1_000_000, TUtf16Char] | |
| const | |
| utf8Encoding = 65001 | |
| proc len(w: WideCString): int = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[ | |
| Author: Ward | |
| Example of GetUserName | |
| References: | |
| https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamea | |
| ]# | |
| import winim/lean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 無圧縮AVIファイル"input.avi"を | |
| * GUIで選択した圧縮形式で圧縮して、"output.avi" に出力するだけのプログラム | |
| */ | |
| #include <Windows.h> | |
| #include <tchar.h> | |
| #include <Vfw.h> | |
| #pragma comment(lib, "vfw32.lib") | |
| #include <GdiPlus.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import numpy as np | |
| # 0 <= h <= 179 (色相) OpenCVではmax=179なのでR:0(180),G:60,B:120となる | |
| # 0 <= s <= 255 (彩度) 黒や白の値が抽出されるときはこの閾値を大きくする | |
| # 0 <= v <= 255 (明度) これが大きいと明るく,小さいと暗い | |
| # ここでは青色を抽出するので120±20を閾値とした | |
| LOW_COLOR = np.array([100, 75, 75]) | |
| HIGH_COLOR = np.array([140, 255, 255]) |