#Transducers

Karsten Schmidttoxi@mastodon.thi.ng
2025-04-24

Added a new convenience transducer for clipping and binning values, e.g. as preparation step for histogram generation whilst working in the REPL. New release forthcoming. A small code example attached (actually taken from the doc string of the new `binned()` transducer).

#ThingUmbrella #Transducers #FunctionalProgramming #ASCIIArt #DataViz #TypeScript #JavaScript

Screenshot of syntax-highlighted TypeScript source code to compute histogram of 1 million gaussian random samples (aka normal distribution), using binned values and discard those outside configured interval. The histogram is then sorted by (bin) position and the values plotted as ANSI-art diagram
CERT & Shree Ram Group MeerutCERTSRS_Official
2025-03-28

🔊 Session Highlights 🚀

What an insightful session on **Smart Sensors & Transducers** with Mr. Davendra Yadav (Principal, CERT Group of Institutions, Meerut)! 🌟

From understanding how sensors shape our daily lives to exploring cutting-edge innovations transforming industries, this session was packed with valuable knowledge! 💡✨

CERT & Shree Ram Group MeerutCERTSRS_Official
2025-03-27

🚀 Join the Brainstorming Session on Smart Sensors & Transducers! 🔍⚡
Gain insights into the role of Smart Sensors & Transducers in our Daily Life with Mr. Davendra Yadav (Principal) at CERT Group of Institutions, Meerut.
📅 Date: 27th March 2025
⏰ Time: 02:00 PM
📍 Venue: Smart Board Room, F-Block

📢 Don't Miss Out – Be a Part of This Transformative Learning Experience!

Jeremy 🇨🇦thatgeoguy@coales.co
2024-08-27

@weavejester I actually think this is probably wrong! "induce" reminds me of induction, and no values are being induced (this is often related to dependent types and having some sort of inductively defined type or value).

I'll play with it some more, it may be that I need to call it transduce-once or transduce-one (onceduce? lol that's terrible).

#Scheme #transducers #Clojure

Jeremy 🇨🇦thatgeoguy@coales.co
2024-08-23

Had an idea a couple days ago while writing one of the chapters of the transducers book: it would be very useful to be able to transduce over a single value, if only to test that your transducer / collector will do what you expect it to do.

I've called it once: gitlab.com/ThatGeoGuy/chicken-

I'm not sure this is the best name for it, so maybe fedi can help me get a better name?

#Scheme #Clojure #Transducers

Karsten Schmidttoxi@mastodon.thi.ng
2024-08-19

Someone asked for help on an interesting transducers (functional programming) problem. My initial answer using other existing transducers still had some minor differences to their intended behavior, but writing a small custom transducer then saves the day and now I can already think of a bunch of other uses for it too:

Attempt #1:
github.com/thi-ng/umbrella/iss

Attempt #2 (custom transducer):
github.com/thi-ng/umbrella/iss

#ThingUmbrella #FunctionalProgramming #Transducers #TypeScript

Bead diagram of an operator which receives streams of values from multiple inputs, each at different times/cadences and which then synchronizes these values and emits tuples...
Karsten Schmidttoxi@mastodon.thi.ng
2024-04-26

#ThingUmbrella #ReleaseFriday[1] 🚀 — As announced a couple of weeks ago, a lot of my recent work has been centered around async iterables and addressing the conceptual overlap between the various packages related to those, specifically: thi.ng/transducers-async, thi.ng/rstream, thi.ng/csp, thi.ng/fibers, and partially related, thi.ng/rdom too. Apart from the first package, until recently, none of the others had direct support for async iterables (largely for historic reasons), but they all offer similar operators & functionality (via different means), which I'm slowly consolidating where it makes sense...

Part of this pretty large undertaking has been a complete rewrite of the temporarily deprecated thi.ng/csp package for Communicating Sequential Processes[2] (IMHO one of the most elegant & sane ways to structure larger apps via multiple small, reasonable concurrent processes). The package is active again now (as v3+) albeit constituting a new API (new docs still WIP) and removing any direct transducer-related functionality — this is one aspect of the aforementioned consolidation and now simply assumed to be delegated to the thi.ng/transducers-async and/or non-async thi.ng/transducers packages. I've also included a new small example project showing mixed usage patterns of working with CSP channels and combining them with (async) transducers to create derived views:

Demo:
demo.thi.ng/umbrella/csp-bus/

Source:
github.com/thi-ng/umbrella/blo

Hand in hand with these major changes are smaller and still ongoing updates to thi.ng/rdom, which recently received partial support for embedded async iterables as reactive values inside a UI/DOM component tree. The goal for this package is to become fully decoupled from thi.ng/rstream and focus more on the equally powerful, but more lightweight (since part of the language) async iterables. Adapters from rstream → asynciter already exists (see docs).

Unrelated, but also part of this week's release: The new version of thi.ng/meta-css includes support for CSS `light-dark()`. The base framework now includes ~950 utilities & 70 functions. See readme for full list...

Happy coding! :)

[1] There're actually a lot more frequent release, but these days I'm only mentioning the more notable ones to not spam everyone...

[2] en.wikipedia.org/wiki/Communic

#ThingUmbrella #CSP #Async #Transducers #Reactive #UI #DOM #CSS #TypeScript #JavaScript #OpenSource

Karsten Schmidttoxi@mastodon.thi.ng
2024-04-16

Phew... One key step closer to replicating & simplifying core thi.ng/rstream functionality via just standard async iterables: Just added a `mult()` base-operator to thi.ng/transducers-async [1] which allows splitting a single async iterable into multiple child async iterables (aka subscriptions, aka 1:N splitting), each of which can be added/removed dynamically and individually processed e.g. via transducers, vanilla `for await()` consumers, and/or used as input for downstream `mult()`s to construct entire graph topologies (cycles allowed) of async processors etc. Back pressure is handled by waiting for all child subscriptions to deliver the value before consuming a new one from the source...

[1] github.com/thi-ng/umbrella/blo

#ThingUmbrella #Async #Transducers #ReactiveProgramming #FunctionalProgramming #TypeScript #JavaScript

Karsten Schmidttoxi@mastodon.thi.ng
2024-04-13

For @made and others who might have questions about the new thi.ng/transducers-async library, I've tried to illuminate the behind-the-scenes approach over here:

github.com/thi-ng/umbrella/dis

#ThingUmbrella #Transducers #Async #Generators #TypeScript #JavaScript #FunctionalProgramming

Karsten Schmidttoxi@mastodon.thi.ng
2024-04-11

Sorry for recent silence, if I can summarize most of my past two weeks or so:

"Async all the thi.ngs, what colud posibsyl og wrngo!" [1]

1) New package thi.ng/transducers-async (restarted development after originally stopping it in 2018 due to lack of async iterable support)
2) Updates to thi.ng/rstream (adapters from/to async iterables)
3) Upcoming, a new & simplified implementation of thi.ng/csp (currently still only on a feature branch[2]) for building blocks for Communicating Sequential Processes.
4) Also still WIP only, async iterable support for thi.ng/rdom, i.e. in the same way as rstream subscriptions, such async iterables can soon be directly embedded as component/element bodies or attribute values and then perform pinpointed DOM updates each time their value changes...

As I said, async all the thi.ngs...

[1] h/t @sjb3d for an ancient tweet with a similar sentiment & outcome :)

[2] The CSP package too was somewhat deprecated (for similar reasons) and a while ago I added another alternative CSP implementation via thi.ng/fibers, but that package too might see some more refactoring/simplifying by switching to async generators...

#ThingUmbrella #Async #Transducers #OpenSource #TypeScript #JavaScript

Jeremy 🇨🇦thatgeoguy@coales.co
2024-03-13

If you change "traversables" with #transducers I think you get a pretty clear idea of how #Scheme or #Clojure transducers are different from Rust's Iterator trait.

without.boats/blog/iterators-a

2023-10-10

Has anyone used the new Dayton Audio interchangeable mount system on their #transducers? does it work as well as their regular mounts?

:boost_anim_vanilla:

GripNewsGripNews
2023-09-11

🌘 我對傳輸器的心理模型
➤ Clojure中傳輸器的心理模型及其使用演示
blog.danieljanus.pl/2023/09/09
本文介紹了Clojure中的傳輸器(transducers)的心理模型,並通過REPL會話演示瞭如何使用core.async庫實現傳輸器。傳輸器是一種將傳送帶轉換為其他傳送帶的機制,並且具有可組合性,可以通過組合簡單的構建塊來生成更複雜的數據管道。本文還介紹了Clojure中的一些傳輸器,例如map、remove和partition-all。
+ 這篇文章對於初學者來說非常有用,尤其是通過REPL會話演示瞭如何使用傳輸器。
+ 這篇文章很好地解釋了傳輸器的概念和使用方法,並且通過示例演示瞭如何使用Clojure中的一些傳輸器。

GripNewsGripNews
2023-09-10

🌗 我對轉換器的心智模型
➤ Clojure中轉換器的心智模型
blog.danieljanus.pl/2023/09/09
本文介紹了Clojure中的轉換器(transducers)的概念,並提供了一個直觀的心智模型,幫助讀者理解轉換器的運作方式。作者通過使用core.async庫來實現一個可交互的傳送帶(conveyor belt),並演示瞭如何使用轉換器來轉換數據流。最後,作者通過一個實際案例展示瞭如何使用轉換器來提高系統的性能。
+ 這篇文章對於理解Clojure中的轉換器非常有幫助,作者提供了一個直觀的心智模型,讓人很容易理解轉換器的運作方式。
+ 這篇文章的實際案例非常有用,讓人更好地理解如何使用轉換器來提高系統的性能。
.async

Karsten Schmidttoxi@mastodon.thi.ng
2023-08-28

#HowToThing #008 — CSV parsing & filtering into structured data via thi.ng/csv and creating a multi-plot data visualization via thi.ng/viz (along with a range of other helpful packages for various side aspects).

The attached visualization shows a lin-log plot of new COVID cases between March 2020 - Dec 2021:

- Daily world total as line plot
- UK (red) and USA (blue) cases as interleaved bar plots

(All data from: ourworldindata.org/coronavirus)

Full source code:
gist.github.com/postspectacula

#ThingUmbrella #Transducers #TypeScript #JavaScript #DataViz #CSV #SVG #Tutorial

Screenshot of the 1st part of the TypeScript source code of the linked code example.Screenshot of the 2nd part of the TypeScript source code of the linked code example.Resulting lin-log chart showing daily new COVID19 cases as described in the toot and in the source code of the linked code example.
Karsten Schmidttoxi@mastodon.thi.ng
2023-08-22

#HowToThing #003 Tracking multiple key states and extracting high-level commands from key sequences via thi.ng/rstream & thi.ng/transducers-fsm. The key sequences are stored as a trie and matched via a transducer-based finite state machine.

Btw. The new example #125 of the thi.ng/umbrella monorepo shows an extended version of this approach...

Demo:
demo.thi.ng/umbrella/rdom-key-

Source:
github.com/thi-ng/umbrella/tre

#ThingUmbrella #TypeScript #JavaScript #FSM #Transducers #Tutorial

TypeScript source code (part 1):

import { objectFromKeys } from "@thi.ng/associative";
import { $compile } from "@thi.ng/rdom";
import { fromDOMEvent, merge, trace } from "@thi.ng/rstream";
import { comp, filter, reducer, scan, sideEffect } from "@thi.ng/transducers";
import { fsm } from "@thi.ng/transducers-fsm";

// list of keys we're interested in
const MODIFIERS = ["shift", "control"];
const ALL_KEYS = ["w", "a", "s", "d", "z", "x", "k", ...MODIFIERS];

// object type for tracking multiple pressed keys
type KeyStates = Record<string, boolean>;

// type for finite state machine to recognize key sequences
type KeySeqState = { state: string; choices: Trie };

// recursive type for multi-key command sequences
// https://en.wikipedia.org/wiki/Trie
type Trie = { [id: string]: TrieData };
type TrieData = string | Trie;

// command sequences as nested data structure:
// - nested objects represent sub-sequences
// - strings values are command IDs
// e.g. ctrl+k ctrl+x => "open-explorer" command
const COMMANDS: Trie = {
	control: {
		a: "select-all",
		d: "duplicate",
		k: { w: "close all", s: "save-all", control: { x: "open-explorer" } },
		z: "undo",
		shift: { z: "redo" },
	},
	shift: { control: { z: "redo" } },
};

// create stream of key states by merging DOM event streams and attaching a
// transducer (`xform`) to transform the raw events into a stream of
// `KeyStates` objects...TypeScript source code (part 2) - had issues pasting it here due to char limit, please download & use OCR to recover...Screenshot of the linked example project
Karsten Schmidttoxi@mastodon.thi.ng
2023-08-16

Announcing #HowToThing, small code snippets illustrating useful patterns and use cases for various libraries/projects in the thi.ng ecosystem/anti-framework...

#HowToThing #001:
Build a FPS counter with moving average w/ thi.ng/transducers

Source code in alt text

(Ps. Have been trying to start similar stuff in the past on the birdsite, but let's see if I can control my attention and be more consistent this time... If you have any topic requests, please reply below [or via DM])

#ThingUmbrella #TypeScript #JavaScript #FunctionalProgramming #Transducers #Tutorial

import { fiber } from "@thi.ng/fibers";
import { benchmark, comp, map, movingAverage, step } from "@thi.ng/transducers";

// compose a FPS counter function from multiple transducers
// the `step` function is a wrapper for step-wise execution
const fps = step(
    comp(
        // measure time since last input
        // (the input value itself is irrelevant)
        benchmark(),
        // simple moving average (period=30)
        movingAverage(30),
        // convert time into frequency (frame per second), format
        map((x) => (1000 / x).toFixed(1) + " fps")
    )
);

// example usage
// (in browsers default execution of fibers is via requestAnimationFrame())
fiber(function* () {
    while (true) {
        // compute next step of FPS counter
        // since we're using a moving average of 30,
        // the first 29 frames will not yield any result (returns `undefined`)
        // the logical-OR (`||`) will then choose a fallback string
        const currFps = fps(0) || "[sampling]";
        console.log(currFps);
        // wait until next frame
        yield;
    }
}).run();

// see docs for more details:
// https://docs.thi.ng/umbrella/fibers/
// https://docs.thi.ng/umbrella/transducers/
Josh Halandhalandjoshef
2023-07-05

Ultrasound Transducer Development

Explore a wide range of ultrasound transducer options with Verasonics. Discover the perfect match for your research and diagnostic needs, with options for frequency, aperture, shape, and more.

Visit Us: verasonics.com/transducer-opti

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst