neural/rune/specs/examples.md

examples

← specification index


double a number

// classic
fn double(x: @nebu) -> @nebu { x * 2 }
:: pure
|=  x=@nebu  (mul x 2)

graph reactor — watch, rank, link

// classic
async fn reactor(p: #) {
    loop {
        let _ = hint::particle_changed(p);
        let r = !rank(p);
        if r > 0.5 {
            !cyberlink(p, ^truth, +1);
        }
    }
}
:: pure
|=  p=#
|-
=/  _   ~hint:%particle.p
=/  r   !rank.p
?:  (gth r 0.5)
  !cyberlink.p.^truth.+1
$

trading agent — hint + host + pure

// classic
fn trading_agent(pair: #, model: #) {
    let threshold = 0.7;
    loop {
        let price  = hint::particle_changed(pair);
        let signal = host::infer(model, price.history);
        let conf   = Tri::normalize(signal);
        let sent   = Arc::rank(pair, 100);
        if conf > threshold {
            !cyberlink(pair, ^truth, +1);
        }
        host::gpu(chart_shader, [price, signal, sent]);
    }
}
:: pure
|=  [pair=# model=#]
=/  threshold  .7
|-
=/  price   ~hint:%particle.pair
=/  signal  ~host:%infer.model.price
=/  conf    (normalize:Tri signal)
=/  sent    (rank:Arc pair 100)
?:  (gth conf threshold)
  !cyberlink.pair.^truth.+1
~host:%gpu.[chart-shader [price signal sent]]
$

a neuron as a door

|%
++  identity     ~self
++  follow       |=  who=@   !cyberlink:~self:who:+1
++  unfollow     |=  who=@   !cyberlink:~self:who:-1
++  pulse        |-          =.  ~now  ~hint:%tick   $
--

dynamic — load and run code from the graph

=/  code   #~/agents/trader
=/  ast    (parse code)
=/  form   (lower ast)
=/  sub    [~self ~now ~here ~caps ~mem ~world]
.*(sub form)

Homonyms

cyb/prysm/examples
examples
soft3/mudra/examples
examples
soft3/radio/iroh-willow/examples
examples
soft3/radio/iroh/examples
examples
cyb/honeycrisp/rane/examples
examples
soft3/tru/rs/examples
examples
soft3/nox/rs/examples
examples
cyb/honeycrisp/aruminium/examples
examples/ runnable demos. each one is self-contained and shows a real GPU workflow. | file | what it does | |------|-------------| | `vecadd.rs` | vector addition on GPU — simplest possible compute dispatch | | `matmul.rs` | matrix multiplication — tiled compute with shared memory |
soft3/glia/run/examples
examples
bootloader/go-cyber/js/examples
examples
cyb/honeycrisp/unimem/examples
examples
cyb/honeycrisp/acpu/examples
examples
soft3/radio/iroh-dns-server/examples
examples
soft3/radio/iroh-docs/examples
examples
soft3/radio/iroh-gossip/examples
examples
soft3/radio/iroh-blobs/examples
examples
cyb/evy/crates/evy_engine_core/examples
examples
cyb/evy/forks/bevy_tasks/examples
examples
cyb/evy/forks/bevy_ecs/examples
examples

Graph