From d4b032f1566a6f33eee1b3e9e4ab94845fb64735 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Tue, 8 Sep 2026 19:20:25 +0200 Subject: [PATCH] csys: provide generic synapse op: modify-value --- csys/csys.lisp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index e484707..6610c5f 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -14,7 +14,7 @@ #:neuron #:std-proc #:eff-proc #:handle-action #:basic-actions #:forward #:notify #:no-op #:printer #:value-add #:create #:connect - #:multiply + #:modify-value #:multiply #:divide #:send-message #:send-create #:send-connect #:send-switch)) (in-package :scopes/csys) @@ -154,7 +154,7 @@ (setf (value scope) (shape:data-value msg :value)) (values msg scope))) -(defun value-add (&key (bias 0) (threshold 1) (limits '(0 10))) +(defun value-add (&key (bias 0) (threshold 1) (limits '(0 15))) (lambda (msg scope) (let* ((val (getf (shape:data msg) :value)) (newval (+ val (value scope))) @@ -210,12 +210,18 @@ ;;;; synapse ops -(defun multiply (n) +(defun modify-value (fn &rest args) (lambda (msg) - (let* ((data (copy-list (shape:data msg)))) - (setf (getf data :value) (* (getf data :value 0) n)) + (let ((data (copy-list (shape:data msg)))) + (setf (getf data :value) (apply fn (getf data :value 0) args)) (message:create (shape:head msg) :data data)))) +(defun multiply (n) + (modify-value #'* n)) + +(defun divide (n) + (modify-value #'floor n)) + ;;;; public shortcuts (defun send-message (cell head data)