Skip to content

Instantly share code, notes, and snippets.

@coord-e
Last active August 8, 2020 10:22
Show Gist options
  • Save coord-e/5452430b652642f6a0b67d5ecc727f00 to your computer and use it in GitHub Desktop.
Save coord-e/5452430b652642f6a0b67d5ecc727f00 to your computer and use it in GitHub Desktop.
増やせ!
### {
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))
}
}
@append_text(a) {
@(b) {
`{a}{b}`
}
}
Plugin:register_post_form_action("増やす" @(form update) {
#r = parse_num_attr(form.text, 1)
#text = apply_times(append_text(r.rest) 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