Last active
August 8, 2020 10:22
-
-
Save coord-e/a617790a15d55d9e5ac42ed2cc440614 to your computer and use it in GitHub Desktop.
回せ!
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
### { | |
name: "回す" | |
version: "0.0.1" | |
author: "coord_e" | |
description: "回せ!" | |
} | |
@parse_num_attr(text def) { | |
#arr = Str:split(text, " ") | |
? (Arr:len(arr) = 0) { | |
<< { num: def, rest: text } | |
} | |
#last = arr[Arr:len(arr)] | |
#may_num = Str:to_num(last) | |
? (may_num = _) { | |
{ num: def, rest: text } | |
} . { | |
Arr:pop(arr) | |
#init = Arr:join(arr, " ") | |
{ num: may_num, rest: init } | |
} | |
} | |
@apply_times(f n a) { | |
? (n = 0) { | |
a | |
} . { | |
apply_times(f (n - 1) f(a)) | |
} | |
} | |
@wrap_with(tag) { | |
@(text) { | |
`<{tag}>{text}</{tag}>` | |
} | |
} | |
Plugin:register_post_form_action("回す" @(form update) { | |
#r = parse_num_attr(form.text, 1) | |
#text = apply_times(wrap_with("spin") r.num r.rest) | |
update("text" text) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment