Created
July 12, 2024 03:55
-
-
Save narskidan/b7d435ac72b50a90d55ee3e20c0ae6e3 to your computer and use it in GitHub Desktop.
Sleep sort with Gall agent & Behn
This file contains 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
/+ default-agent, dbug | |
|% | |
+$ versioned-state | |
$% state-0 | |
== | |
+$ state-0 | |
$: [%0 length=@ud values=(list @)] | |
== | |
+$ card card:agent:gall | |
-- | |
%- agent:dbug | |
=| state-0 | |
=* state - | |
^- agent:gall | |
|_ =bowl:gall | |
+* this . | |
default ~(. (default-agent this %|) bowl) | |
++ on-init | |
^- (quip card _this) | |
~& > '%bravo initialized successfully' | |
=. state [%0 0 *(list @)] | |
`this | |
++ on-save on-save:default | |
++ on-load on-load:default | |
++ on-poke | |
|= [=mark =vase] | |
^- (quip card _this) | |
?> ?=(%sortable mark) | |
=/ sortable !<((list @) vase) | |
:_ this(state [-.state (lent sortable) `(list @)`~]) | |
%+ turn | |
sortable | |
|=(s=@ud [%pass /timer/(scot %ud s) %arvo %b %wait (add now.bowl `@dr`(mul s `@ud`~s1))]) | |
++ on-arvo | |
|= [=wire =sign-arvo] | |
^- (quip card _this) | |
?> ?=([%timer *] wire) | |
=/ sorted `@ud`(slav %ud `@t`-.t.wire) | |
`this(state [-.state length.state (snoc values.state sorted)]) | |
++ on-watch on-watch:default | |
++ on-leave on-leave:default | |
++ on-peek | |
|= =path | |
^- (unit (unit cage)) | |
``noun+!>([=((lent values.state) length.state) values.state]) | |
++ on-agent on-agent:default | |
++ on-fail on-fail:default | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage (in the Dojo):