Skip to content

Instantly share code, notes, and snippets.

@crcx
Forked from lsparrish/gist:273222
Created January 10, 2010 07:29
Show Gist options
  • Save crcx/273364 to your computer and use it in GitHub Desktop.
Save crcx/273364 to your computer and use it in GitHub Desktop.

Original

{{
  : :find ( a-af ) last repeat @ 2dup =if drop @ -1 ;; else dup 0 =if ;then then again ;
  : .vocab ( a- ) dup 1+ @ :find nip if shut else open then ;
---reveal---
  : as-vocab ( a- ) last @ d->class ['] .vocab swap ! ;
}}

Cleanups

First cleanup is to "as-vocab":

: as-vocab ( a- ) ['] .vocab reclass ;

Next, ".vocab":

: .vocab ( a-   ) dup 1+ @ :find nip if shut ;then open ;

And then ":find":

: :find  ( a-af ) last repeat @ 2dup =if drop @ TRUE ;then dup 0; drop again ;

Final Code

{{
  : :find  ( a-af ) last repeat @ 2dup =if drop @ TRUE ;then dup 0; drop again ;
  : .vocab ( a-   ) dup 1+ @ :find nip if shut ;then open ;
---reveal---
  : as-vocab ( a- ) ['] .vocab reclass ;
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment