jespada's avatar
jespada
jespada@jespada.dev
npub1747c...4uzf
https://primal.net/jespada
jespada's avatar
jespada 10 months ago
jespada's avatar
jespada 1 year ago
#meatstr like every other weekend image
jespada's avatar
jespada 1 year ago
GM, the 🌞 and git stash are your friends, use them #git #GM
jespada's avatar
jespada 1 year ago
Here's a simple example in Guile Scheme to demonstrate the concept of transducers. Transducers are composable algorithmic transformations that can be applied to sequences without changing how the sequence is processed. This example will show how to create and compose transducers for mapping and filtering operations. scheme ;; Define a simple transducer for mapping (define (mapping f) (lambda (rf) (lambda (result input) (rf result (f input))))) ;; Define a simple transducer for filtering (define (filtering pred) (lambda (rf) (lambda (result input) (if (pred input) (rf result input) result)))) ;; A simple reducing function that appends to a list (define (append-to-list result input) (cons input result)) ;; Helper function to reduce a list using a transducer (define (transduce transducer coll reducer init) (let* ((rf (transducer reducer)) (result (fold rf init coll))) result)) ;; Example usage (let* ((numbers (list 1 2 3 4 5 6)) ;; Define our transducers (double (mapping (lambda (x) (* x 2)))) (even (filtering even?)) ;; Compose transducers (composed-transducer (lambda (rf) (even (double rf)))) ;; Use transduce to apply our composed transducer (result (transduce composed-transducer numbers append-to-list '()))) (display result)) Explanation: Mapping: The mapping transducer takes a function f and returns a new reducing function that applies f to each input before passing it to the original reducer. Filtering: The filtering transducer takes a predicate pred and only passes inputs that satisfy the predicate to the reducer. Transduce: This function applies the transducer to each element in the collection, reducing it with the given initial value and reducing function. When you run this code, it will double each number in the list and then filter for even numbers, resulting in a list of (12 8 4) because 2 * 6 = 12, 2 * 4 = 8, and 2 * 2 = 4 are the only even results from doubling the numbers from 1 to 6. #lisp #guile
jespada's avatar
jespada 1 year ago
β˜€οΈ eyes till 1M ? #bitcoin
jespada's avatar
jespada 1 year ago
The stack IYKYK #bitcoin #red #coldcard image
jespada's avatar
jespada 1 year ago
Is this a flex? primal.net/jespada
jespada's avatar
jespada 1 year ago
@Vitor Pamplona I'm trying to use cdn.satellite.earth as media server, tho I paid , I the the error in the pic below, what am I doing wrong ? image
jespada's avatar
jespada 1 year ago
nitric oxide(NO) deficiency in the blood vessels of the genitals is the primary defect in erectile dysfunction. So β˜€οΈ your πŸ₯œ
↑