h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
309 stars 23 forks source link

Proposal: take #30

Closed mwgkgk closed 6 years ago

mwgkgk commented 6 years ago

Currently shorten throws Quotation too short error when the quotation is shorter than the given argument. If all we want is to make sure the quotation is no longer than X, a forgiving version of shorten could be useful.

Minlang version:

; quot int -> quot
( :i =q
  (q size i >)
  (q i shorten)
  (q)
  if
) :take

Haskell's take behaves like this. Racket's take raises an exception. In both cases there's also drop counterpart.

All in all, just an idea, as using min version works perfectly fine.

mwgkgk commented 6 years ago

Just noticed that vim syntax file actually considers take a keyword (but not drop): https://github.com/h3rald/min/blob/master/min.vim#L14

h3rald commented 6 years ago

Ohhh yes, that would be useful indeed, I like the Haskell take and drop. Sure, I'll add them as soon as I get a chance, thanks!