★Twigでlispを作ってるんだナ! (9レス)
上
下
前
次
1-
新
5
: 07/07(日)18:01
ID:Z9WWCnLov(4/8)
AA×
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
5: [] 2024/07/07(日) 18:01:55.50 ID:Z9WWCnLov {% else %}{% set result = "false" %}{% endif %}{% elseif a == 'neq?' %}{% if b != c %}{% set result = "true" %}{% set expra = expr[1] %} {% set expra = expra|trim('(')|trim(')')|trim %}{% set components = expra|split(' ') %}{% set operator = components[0] %} {% set operands = components[1:] %}{{_self._keisan(operator,operands)}} {% else %}{% set result = "false" %}{% endif %}{% endif %}{% else %} {% set result = "Unknown operation" %}{% endif %}{{ result }} {% endmacro %}{% macro _keisan(operator,operands) %}{% set num = 1 %} {% if operator == '+' %}{% set result = operands|reduce((acc, item) => acc + item|number_format) %}{{ result }} {% elseif operator == '-' %} {% for item in operands %}{% if num == 1 %}{% set totalPrice = item|number_format %}{% set num = num + 1 %}{% else %}{% set num = num + 1 %} {% set totalPrice = totalPrice - item|number_format %}{% endif %}{% if num == operands|length + 1 %}{{ totalPrice }} {% endif %}{% endfor %} {% elseif operator == '*' %}{% set result = operands|reduce((acc, item) => acc * item|number_format,1) %}{{ result }} {% elseif operator == '/' %} {% for item in operands %}{% if num == 1 %}{% set totalPrice = item|number_format %}{% set num = num + 1 %}{% else %}{% set num = num + 1 %} {% set totalPrice = totalPrice / item|number_format %}{% endif %}{% if num == operands|length + 1 %}{{ totalPrice }} {% endif %}{% endfor %} {% elseif operator == 'print' %}{% for item in operands %}{{ operands[p|number_format] }} {% set p = p + 1 %}{% endfor %}{% endif %}{% endmacro %} {{ _self.evaluate("(+ 1 2 6)") }}{{ _self.evaluate("(* 2 3 2)") }}{{ _self.evaluate("(- 10 3 2)") }} {{ _self.evaluate("(/ 15 3)") }} {{ _self.evaluate("(if (eq? 3 3))(+ 1 2 6)") }}{{ _self.evaluate("(if (neq? 3 1))(+ 1 2 6)") }}{{ _self.evaluate("(for (range 6))(print doo") }}{{ _self.evaluate("(print shark") }} http://toro.2ch.sc/test/read.cgi/tech/1720270991/5
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 4 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.037s