Ahmed Fasih

Ahmed Fasih

31 thoughts; 9 streams
last posted Oct. 1, 2016, 8:16 a.m.
0
Joined on April 26, 2016, 2:22 p.m.
get recent cards as: atom

From Marshall Sahlins’ Stone Age Economics

“We cultivate our gardens, waiting to see if the gods will shower rain or, like those of certain New Guinea tribes, just urinate upon us.”

The traditional wisdom is always refractory. One is forced to oppose it polemically, to phrase the necessary revisions dialectically.

4 thoughts
updated Aug. 2, 2016, 3:57 p.m.

We usually emphasize the requirement for linear phase, because linear phase is not an attribute of recursive analog filters, and is purchased by the use of additional filters known as phase equalizer filters. We know that linear phase shift, a property equivalent to pure time delay, can never be achieved exactly with lumped linear circuit components but can be achieved with distributed components which form transmission lines that respond with solutions to the wave equation. Analog phase equalizers in the analog domain are used to obtain equiripple approximations to linear phase slope.

The attraction, and an often-cited advantage, of nonrecursive filters is the ease with which they can achieve linear phase shift. To achieve linear phase in a FIR filter, its impulse response must exhibit symmetry with respect to its center point. We thus find that linear phase shift, a difficult attribute to achieve in the analog domain, is essentially free in the sampled data domain. For reasons that escape us, additional discussion of distortion effects seems to stop here as if access to linear phase has solved the problem. This is a bit premature since we still have to address the effect of equiripple deviation from constant amplitude gain as well as the effect of the equiripple deviation from uniform phase shift of the phase equalized recursive filter.

—Fred Harris, “Multirate signal processing for communication systems” (2004). Pages 67–68.

2 thoughts
updated July 7, 2016, 3:30 p.m.
6 thoughts
updated June 14, 2016, 4:49 p.m.
2 thoughts
updated May 28, 2016, 1:18 a.m.

Realists tend not to draw sharp distinctions between “good” and “bad” states, because all great powers act according to the same logic regardless of their culture, political system, or who runs the government. … States may cooperate with each other on occasion, but at root they have conflicting interests.

6 thoughts
updated May 26, 2016, 5:47 p.m.

http://www.appstate.edu/~marshallst/GLY1101/lectures/17-Streams&Floods.pdf

Beautiful slides from Dr Scott Marshall's course, Introduction to Physical Geology at Appalachian State.

How sheetwash (running water over flat, sloped ground) inevitably finds the weakest part of the ground and carves a stream into it. And then grows uphill/upstream as the uptick in speed at the beginning of the channels erode faster than elsewhere!

If that's the birth of a stream, is depositing load at slowdowns its death? “Any time a stream slows down, it deposits some of its sediment.”


We see dendritic, radial, and trellis drainage networks in texture-shaded maps! The last of these, e.g., are immediately visible in my first texture-shadings of the Sichuan Basin, where one can readily see rivers cutting through otherwise resistant ridges. Words can hardly express how beautiful I find the thought of water, falling from the sky, sculpting land.


Crazy thought: the rock under your feet, after a while, is completely saturated with water. It's called a water table. In most parts of Ohio, USA, the depth to the water table isn't more than 6 feet (~2 meters).


Aha! I often wonder at terraces like this: a broad-ish floodplain with plateaued rises. (A "base level" is the depth below which a stream can't cut.)


“In ~60,000 yrs, the [Niagara] falls will erode all the way back to Lake Erie.” Future alternative history!


Braided streams, which carry a lot of sediment during storms but not during regular flow, can't cut deep channels. Handy to know when driving around.


Awesome! Textbooks do include suggested readings! (From Marshak's Earth: Portrait of a Planet (textbook for the Appalachian State course). And yet no fiction, or even whatever genre McPhee's Annals of the Former World could be. I would love to see Annals as richly illustrated as a geology textbook.

2 thoughts
updated May 3, 2016, 12:27 a.m.

Lein tips:

  • With Figwheel & ClojureScript: rlwrap lein figwheel dev (note rlwrap) helps deal with arrow keys.
  • If I had a dollar for every time I’ve typed (require '[clojure.string :as string]) or something similar into the REPL… mnngfltg delivers how to load this in your “lein user profile”. I’m not yet sure how to load cljs/clj-specific ones yet.
2 thoughts
updated April 27, 2016, 1:54 p.m.

Rewrite Matthias Felleisen’s books in Clojure

At https://youtu.be/XTl7Jn_kmio?t=58m36s

1 thought
updated April 26, 2016, 4:48 p.m.

Been looking for new places to live & complaining about the truly absurd cost of home ownership in USA.

Thank you Auburn’s Rural Studio: http://www.fastcoexist.com/3056129/this-house-costs-just-20000-but-its-nicer-than-yours/16

(There must be a word to describe that “it’d be a mighty shame if this doesn’t already exist”.)

1 thought
updated April 26, 2016, 2:38 p.m.
4 thoughts
updated Aug. 2, 2016, 3:57 p.m.
2 thoughts
updated July 7, 2016, 3:30 p.m.
2 thoughts
updated May 28, 2016, 1:18 a.m.
6 thoughts
updated June 14, 2016, 4:49 p.m.
2 thoughts
updated May 3, 2016, 12:27 a.m.
1 thought
updated April 26, 2016, 4:48 p.m.
2 thoughts
updated April 27, 2016, 1:54 p.m.
1 thought
updated April 26, 2016, 2:38 p.m.

Streams by this user that have been favorited by others.

No favorited streams yet.

0

Dalai Lama’s “Essence of the Heart Sutra”.

Caring about others and not just yourself ⇔ spiritual development ⇔ “inner disarmament”. A powerful set of relationships:

In fact, in all levels of our existence—family life, social life, working life, and political life—inner disarmament is, above all, what humanity needs.

0

Happy by Roko Belic and co.

People respond really well to really bad events.

The nervous system is an integrator—it integrates differences, all it can tell are differences.

People who get in flow more are happier.

And more about the historic-sociological insights I was after—after basic needs are met, about where one can shelter and when one can eat, a person’s natural happiness can be expressed. So slums—that’s sufficient stability(?) to provide happiness to flourish.

0

I saw this hill behind Belmont High School (texshade):

And was excited about a grand vista!

On Google Earth though, I saw that the hill was ~15 meters taller than the front of the school…

In contrast, the big blob of elevation at the northwest corner of that crop is Woodland Cemetery, where they buried the Wright Brothers. That offers ~50 meters of overlook above downtown Dayton.

This is what 20 meters looks like 😝:

0

Mongols.

Can pacifists survive? Is non-violence useful after you’ve finished resisting your oppressors?

0

Rollup notes:

  • Don’t name your module or file something with a dash. globals.my-module = ... is no good.
  • Rollup plugin order matters: [ npm({jsnext : true}), commonjs({ignoreGlobal : true}), babel() ] worked when flipping last two didn’t.
  • Add sourceMap: true, sourceMapFile: 'module.js.map' in your Rollup config. And use resulting sourcemaps in Node: https://github.com/evanw/node-source-map-support. It’s easy!
0

Dalai Lama’s “Essence of the Heart Sutra”.

Caring about others and not just yourself ⇔ spiritual development ⇔ “inner disarmament”. A powerful set of relationships:

In fact, in all levels of our existence—family life, social life, working life, and political life—inner disarmament is, above all, what humanity needs.

0

Happy by Roko Belic and co.

People respond really well to really bad events.

The nervous system is an integrator—it integrates differences, all it can tell are differences.

People who get in flow more are happier.

And more about the historic-sociological insights I was after—after basic needs are met, about where one can shelter and when one can eat, a person’s natural happiness can be expressed. So slums—that’s sufficient stability(?) to provide happiness to flourish.

0

I saw this hill behind Belmont High School (texshade):

And was excited about a grand vista!

On Google Earth though, I saw that the hill was ~15 meters taller than the front of the school…

In contrast, the big blob of elevation at the northwest corner of that crop is Woodland Cemetery, where they buried the Wright Brothers. That offers ~50 meters of overlook above downtown Dayton.

This is what 20 meters looks like 😝:

0

Mongols.

Can pacifists survive? Is non-violence useful after you’ve finished resisting your oppressors?

0

Rollup notes:

  • Don’t name your module or file something with a dash. globals.my-module = ... is no good.
  • Rollup plugin order matters: [ npm({jsnext : true}), commonjs({ignoreGlobal : true}), babel() ] worked when flipping last two didn’t.
  • Add sourceMap: true, sourceMapFile: 'module.js.map' in your Rollup config. And use resulting sourcemaps in Node: https://github.com/evanw/node-source-map-support. It’s easy!
0

From Marshall Sahlins’ Stone Age Economics

“We cultivate our gardens, waiting to see if the gods will shower rain or, like those of certain New Guinea tribes, just urinate upon us.”

The traditional wisdom is always refractory. One is forced to oppose it polemically, to phrase the necessary revisions dialectically.

0

Goodreads accidentally reminded me of this very nice review by Jan-Maat of Sahlins’ Stone Age Economics.

The first essay in the book "The Original Affluent Society" is something anybody should have a go at reading. A director could even make a nice documentary film about its subject which is the lives of surviving stone-age hunter gatherers in Africa and Australia. The key finding is that even restricted to fairly desert areas they barely have to work to feed and support themselves. An average of a few hours of work a day are sufficient to meet all their needs. The pace of work is slow. People take naps. People sleep a lot. In short Eden was a reality for our most distant ancestors. Our world by contrast has starvation, poverty and infinite needs that can leave us knowing a dissatisfaction alien to the old stone-age. Something to think about.

Downloaded—sounds beautiful!

0

Taleb’s development of skin in the game, to the logical extreme of clawbacks for downstream harm, is attractive for many reasons, but note how it removes the intellectual equivalent of limited liability that a corporation has (where, even if your corporation fails because of mismanagement, your creditors cannot claim your personal assets and leave you penniless).

Currently who develop ideas are completely protected from the results of those ideas—people like Karl Marx (whose children apparently starved while he was working on Das Kapital) or Ayn Rand. It seems a bad idea to try and subsequently punish people for inventing incorrect or destructive ideas—it’s just impossible.

But all is not lost. We can leave thinkers and makers with limited liability, yet reap many rewards by adopting a simple heuristic: ideas from people without skin-in-the-game are just not worth considering. The risk that a writer took in simply writing tract—philosophical or social or business—is limited to opportunity cost (they risked a livelihood by not working). So again, as a heuristic, just ignore the outputs of authors and proponents without skin-in-the-game.

This isn’t any kind of silver bullet. The heuristic can be easily defeated by finding people who do want to put their skin in the success of some idea—do-gooders will fight globalization, Greenpeace will fight GMOs, and soldiers will die obeying Stalin.

So while skin-in-the-game provides a useful heuristic to protect one from a small set of viral ideas that might invade our minds and bewitch us, life remains complicated.

0

John Kay’s Obliquity (essay version). Preface begins discussing a very interesting topic: “Our customers didn’t really use these models for their decision making… they used them internally or externally to justify decisions that they had already made. They were playing what I now call Franklin’s Gambit, after the American polymath Benjamin Franklin. He wrote: ‘so convenient a thing is it to be a reasonable creature, since it enables one to find or make a reason for everything one had a mind to do’.”

But the rest of the book doesn’t really talk about this. You’ll have to read this excellent article in FT about this topic: “Beware of Franklin’s Gambit in making decisions” (paywall? gist).

0

We usually emphasize the requirement for linear phase, because linear phase is not an attribute of recursive analog filters, and is purchased by the use of additional filters known as phase equalizer filters. We know that linear phase shift, a property equivalent to pure time delay, can never be achieved exactly with lumped linear circuit components but can be achieved with distributed components which form transmission lines that respond with solutions to the wave equation. Analog phase equalizers in the analog domain are used to obtain equiripple approximations to linear phase slope.

The attraction, and an often-cited advantage, of nonrecursive filters is the ease with which they can achieve linear phase shift. To achieve linear phase in a FIR filter, its impulse response must exhibit symmetry with respect to its center point. We thus find that linear phase shift, a difficult attribute to achieve in the analog domain, is essentially free in the sampled data domain. For reasons that escape us, additional discussion of distortion effects seems to stop here as if access to linear phase has solved the problem. This is a bit premature since we still have to address the effect of equiripple deviation from constant amplitude gain as well as the effect of the equiripple deviation from uniform phase shift of the phase equalized recursive filter.

—Fred Harris, “Multirate signal processing for communication systems” (2004). Pages 67–68.

0

The most striking advantage of FIR filters is that they can be designed to have exact linear phase. In situations where linearity of phase is not important, it is sometimes preferable to use IIR filters because an IIR filter usually requires a much lower order for the same set of magnitude response specifications. This implies fewer multipliers and adders.

For various reasons, a comparison of IIR and FIR filters is more involved than the above remark appears to imply. First, there exist techniques (which are perhaps less readily available), for the design of nonlinear phase FIR filters. For a given magnitude response specification, such FIR filters are less expensive than the linear phase versions. Second, there are some commercial signal processing chips, specifically tailored for the implementation of FIR filters. In these chips, the implementation of IIR filters is not necessarily more efficient. Finally, there exist multistage design techniques for the design of narrowband FIR filters which are sometimes more efficient than IIR filters. It is, therefore, difficult to provide a comparison that is fair under all contexts. In this text, we will merely compare the number of multiplications and additions. It should be cautioned that in many cases these do not provide a good measure of complexity.

— P.P. Vaidyanathan, “Multirate systems and filter banks” (1993). Page 60.

Again: It is, therefore, difficult to provide a comparison that is fair under all contexts. In this text, we will merely compare the number of multiplications and additions. It should be cautioned that in many cases these do not provide a good measure of complexity.

0

Amazon Prime, you advertise … Doctor Thorne … while we watching The Wire? (Tweeted 9 hours ago.)

0

Realists tend not to draw sharp distinctions between “good” and “bad” states, because all great powers act according to the same logic regardless of their culture, political system, or who runs the government. … States may cooperate with each other on occasion, but at root they have conflicting interests.

0

The first [theory] argues that high levels of economic interdependence among states make them unlikely to fight each other.

I very much suspect this theory is untrue. It seems a cruel joke to think that “prosperous states are more economically satisfied and satisfied states are more peaceful”.

The second theory of liberal international relations in Mearsheimer’s view is the “democratic peace theory, claims that democracies do not go to war against other democracies”. Also seems very naive.

The third involves international institutions, i.e., “sets of rules that stipulate the ways in which states should cooperate and compete with each other” help curb war. The Marquis of Fantailler…

0

Early on, Mearsheimer notes,

The [first?] Clinton administration’s foreign policy rhetoric, for example, was heavily informed by the three main liberal theories of international relations: 1) the claim that prosperous and economically interdependent states are unlikely to fight each other, 2) the claim that democracies do not fight each other, and 3) the claim that international institutions enable states to avoid war and concentrate instead on building cooperative relationships.

The likely or eventual correctness of these three hypotheses are not commented on here. Later, Mearsheimer expounds on the differences between the liberal and the realist schools of international relations thought:

liberals tend to be hopeful about the prospects of making the world safer and more peaceful. Most liberals believe that it is possible to substantially reduce the scourge of war and to increase international prosperity. For this reason, liberal theories are sometimes labelled “utopian” or “idealist.”

He horrifyingly continues, and I’m waiting for the beat to drop because this cannot end well:

Liberalism’s optimistic view of international politics is based on three core beliefs, which are common to almost all of the theories in the paradigm. … [The first and the third are not as terrifying as the second] Second, they emphasize that the internal characteristics of states vary considerably, and that these differences have profound effects on state behavior. Furthermore, liberal theorists often believe that some internal arrangements (e.g., democracy) are inherently preferable to others (e.g., dictatorship). For liberals, therefore, there are “good” and “bad” states in the international system. Good states pursue cooperative policies and hardly ever start wars on their own, whereas bad states cause conflicts with other states and are prone to use force to get their way. Thus, the key to peace is to populate the world with good states.

He concludes his description of the pillars of the liberal view of international politics with

Bad states might be motivated by the desire to gain power at the expense of other states, but that is only because they are misguided. In an ideal world, where there are only good states, power would be largely irrelevant.

0

Mearsheimer poses the following questions:

First, why do great powers want power? What is the underlying logic that explains why states compete for it? Second, how much power do states want? How much power is enough? … Third, what is power? How is that pivotal concept defined and measured? … Fourth, what strategies do states pursue to gain power, or to maintain it when another great power threatens to upset the balance of power? … The fifth is, what are the causes of war? Specifically, what power-related factors make it more or less likely that security competition will intensify and turn into open conflict? Sixth, when do threatened great powers balance against a dangerous adversary and when do they attempt to pass the buck to another threatened state?

Some guesses. First, without power, states fear they will be subjugated (from Machiavelli, despite Keltner).

Second, every state wants to be the most powerful state, number one—that’s the only way to be secure (assuming an unchanging world).

Third, I… am not sure.

Fourth: war. Shooting or trade war. Though, I’m only partly right, for right here Mearsheimer says, “Blackmail and war are the main strategies that states employ to acquire power, and balancing and buck-passing are the principal strategies that great powers use to maintain the distribution of power when facing a dangerous rival.”

Fifth. See #4.

Sixth. I don’t know.

0

On May 12–13, I highlighted these:

These and other propositions in this book will be controversial. In their defense I try to show that the logic that underpins them is sound and compelling. I also test these propositions against the historical record.

the structure of the international system forces states which seek only to be secure nonetheless to act aggressively toward each other. Three features of the international system combine to cause states to fear one another: 1) the absence of a central authority that sits above states and can protect them from each other, 2) the fact that states always have some offensive military capability, and 3) the fact that states can never be certain about other states’ intentions. Given this fear—which can never be wholly eliminated—states recognize that the more powerful they are relative to their rivals, the better their chances of survival.

“I have every sympathy for their situation, but if we wish to survive we have no choice but to wipe them out.” —Bismark on the Poles

Whether China is democratic and deeply enmeshed in the global economy or autocratic and autarkic will have little effect on its behavior, because democracies care about security as much as non-democracies do, and hegemony is the best way for any state to guarantee its own survival.

Let us continue live-tweeting this book.

0

It all started with Stephen Walt’s How to Get a B.A. in International Relations in 5 Minutes (onerous paywall, so here’s a pirated copy). I didn’t dare pray for such lucidity on the topic of international relations:

  1. Anarchy There’s no policeman or court that protects you from criminals in the international arena.
  2. Balance of power/threats Therefore, nations are acutely aware of who is more or less powerful than them, and the rates at which they’re getting or losing power; the strength of alliances, and the rates of strengthening or deterioration of those alliances.
  3. Comparative advantage Nations and peoples can get rich by making the best things they can, or providing the best services they can, and with the money they earn doing so, buying things that they’d like and can’t get as well domestically. You probably read about this in microeconomics class.
  4. Misperception & miscalculation Misunderstandings, miscommunications, needless panic, rule the day. Because of all the above.
  5. Social construction People’s attitudes about huge things (god, moral norms, work, slavery, &c.) are both hugely important and can change quickly.

Walt lets a friend sum up international politics (though, note, that it most likely applies to a lot of other things, though just as imprecisely): “three words: fear, greed, and stupidity.” Numbers 1 & 2 above are about fear. Number 3 is about greed. And number 4 is stupidity. And number 5 just says that the specific things you fear, lust for, and get confused about will change.

Walt has a list of important and interesting books for people interested in international relations somewhere, and on it I found Mearsheimer’s book on power politics.

0

There are a few pillars which I’d make central to my work and personal culture. And I should keep a list of them to return to.

One is Pyrrhonean Skepticism & Buddhist agnosticism, of course, but while it’s hugely influential in my day-to-day work, I’m not sure I can describe it very well—this idea that though you may solve something, or master something, or fix something, and that improves life in one way, something else will assuredly intrude on your awareness to remind you of its unpleasantness. In other words, suffering.

But something that has been written down by someone else that I make central to my approach is Dacher Keltner’s research on power, e.g., The Power Paradox post (also a book). It’s not so much a paradox as an ironic regression:

Power is given to those individuals, groups, or nations who advance the interests of the greater good in socially-intelligent fashion. Yet unfortunately, having power renders many individuals as impulsive and poorly attuned to others… making them prone to act abusively and lose the esteem of their peers. [emphasis mine]

We’re aware that we like people with social intelligence: we give weight to their advice, we are more forgiving of their foibles, and more willing to help them. That’s “power”.

Then, having gotten it, people whom we liked and empowered begin to show rude and graceless behavior. In Keltner’s experimental terms, they stop advancing the greater good and start harming it.

This many people (including myself) are less familiar with, as it requires knowing someone for a long period of time and remembering the good old days. It’s not clear why this happens—it may be a cultural problem. But I am not particularly interested in this as a theoretical problem. Being aware of this paradox, I’d like to live and work in environments where it is part of our vocabulary and something that one can allude to as a response to certain behaviors.

8 years, 6 months ago
1

With all this Firebird on my mind [1], one thing led to another, and I was hit by all of Stravinsky’s Rite of Spring with François-Xavier Roth and Les Siècles on BBC. 💀.

And finished Miyazaki’s acclaimed 風立ちぬ too. Been a heavy night.

[1] Benjamin Carlson also gutsily compared the finale of Firebird to a Paul van Dyk beat. Everything is better with Firebird. Rite of Spring, not so much.

0

I am not a squirmy person, but AOA’s latest album’s title track, Good Luck, is better heard than seen.

That said, it’s pretty amazing—retro synthwave invaded the album’s second track, “10 Seconds”. Coincidence?

0

Music lover Benjamin Carlson advises one to “Name That Emotion” in a classical piece. Not sure if I can do that for one of my favorite pieces, Dohnányi’s piano quintet 1 for piano and string quartet (2 violins, viola, and cello). This recording by the Takacs Quartet and András Schiff is a bit faster than I remember it but has all the wonderful goodness.

(originally tweeted on 2012-02-17 at Z12:39:37)

0

Unexpected pleasure of listening to Lazerhawk’s Redline and seeing three-year-old start bumping in booster seat.

(This all started a few days ago with Youtube recommending Robert Parker’s Crystal City by the apparently prolific NRW Records, viz., New Retro Wave. Crystal City, King Street, Bethesda, Yellow Line, monuments, DCA…!)

0

http://www.appstate.edu/~marshallst/GLY1101/lectures/17-Streams&Floods.pdf

Beautiful slides from Dr Scott Marshall's course, Introduction to Physical Geology at Appalachian State.

How sheetwash (running water over flat, sloped ground) inevitably finds the weakest part of the ground and carves a stream into it. And then grows uphill/upstream as the uptick in speed at the beginning of the channels erode faster than elsewhere!

If that's the birth of a stream, is depositing load at slowdowns its death? “Any time a stream slows down, it deposits some of its sediment.”


We see dendritic, radial, and trellis drainage networks in texture-shaded maps! The last of these, e.g., are immediately visible in my first texture-shadings of the Sichuan Basin, where one can readily see rivers cutting through otherwise resistant ridges. Words can hardly express how beautiful I find the thought of water, falling from the sky, sculpting land.


Crazy thought: the rock under your feet, after a while, is completely saturated with water. It's called a water table. In most parts of Ohio, USA, the depth to the water table isn't more than 6 feet (~2 meters).


Aha! I often wonder at terraces like this: a broad-ish floodplain with plateaued rises. (A "base level" is the depth below which a stream can't cut.)


“In ~60,000 yrs, the [Niagara] falls will erode all the way back to Lake Erie.” Future alternative history!


Braided streams, which carry a lot of sediment during storms but not during regular flow, can't cut deep channels. Handy to know when driving around.


Awesome! Textbooks do include suggested readings! (From Marshak's Earth: Portrait of a Planet (textbook for the Appalachian State course). And yet no fiction, or even whatever genre McPhee's Annals of the Former World could be. I would love to see Annals as richly illustrated as a geology textbook.

0

http://techalive.mtu.edu/meec/module08/GreatLakesFlow.htm

I never knew! Lake Superior empties into Lakes Michigan and Huron. The latter empties into Lake Erie, which empties into Lake Ontario via the mighty Niagara Falls, and eventually to the St. Lawrence and the Atlantic Ocean. Lakes Superior, Michigan, Huron, and Erie are on average a hundred meters higher than lake Ontario, which is ~75 meters above sea level.

0

Lein tips:

  • With Figwheel & ClojureScript: rlwrap lein figwheel dev (note rlwrap) helps deal with arrow keys.
  • If I had a dollar for every time I’ve typed (require '[clojure.string :as string]) or something similar into the REPL… mnngfltg delivers how to load this in your “lein user profile”. I’m not yet sure how to load cljs/clj-specific ones yet.
0

Can’t use -> in update-in (clojuredocs). I.e., if you’re doing this in the REPL:

(-> my-map :a-path :b-path first :c-path second),

to get to a certain path in a map and then apply some function to it (in this case, first, :c-path, and second), and now want to update that path using that function, you’ll need:

(update-in my-map [:a-path :b-path] #(-> % first :c-path second)),

or alternatively,

(update-in my-map [:a-path :b-path] (comp second :c-path first)),

noting how with comp you reverse the order of functions from ->.


I mention this because I prefer using partial or apply or comp to the function literal #()—mainly because I find myself often needing to nest function literals inside function literals, which isn’t allowed—but in this case, because of the reverse-notation-requirement of comp, I preferred the #(-> % …) notation.


It takes some getting used to, these idioms in Clojure—I’ve thought of programming idioms as the preferred way to do something among other options, but here idiom means something quirky that works while plausible-seeming alternatives don’t. And it’s taken a while but there’re a couple of other idioms around how to compose functions: around -> and ->>.

And I love these threading operators to death: in 1530 lines of Clojure (via cloc), these operators appear 117 times (via $ grep -rsn -- "->" * | wc -l), so a little more than ten lines of code between uses of -> and ->>. I don’t use them to thread just one function, but that’s a lot of usage, and I take note because I have no idea how readable these two constructs are down the road or to other developers.

I use them in code because it’s easy to write (in REPL & in the editor). But it’s only easy because I’ve worked out some idioms for their usage and how to convert from one to the other.

E.g., often one uses threading macros and gets a coll (seq, vector, etc.) that needs to be map (or keep or filter &c.). If you were using ->>, you’re fine: (->> [1 2 3] (map inc)) ;✓ . But if you were using ->, perhaps because you were using nth or clojure.string/index-of or some other function that takes the “main variable” as first argument, then you’re in for

  • (-> [1 2 3] (#(map inc %)))
  • (-> [1 2 3] ((partial map inc))) ; note nesting of partial!
  • (-> [1 2 3] (->> ,,, (map inc ,,,))) ; ,,, show threaded positions

All these alternatives smell like they’re going to be trouble for me later, but for now, I’m charging ahead using them because threading macros make coding faster.


Postscript. I think some of the weirdness & contortions needed above would go away if Clojure had right-partials. But given Clojure’s commitment to multi-methods and variable argument functions (which was one plausible reason given online), it doesn’t exist and its use would be prone to later regret.

0

Been looking for new places to live & complaining about the truly absurd cost of home ownership in USA.

Thank you Auburn’s Rural Studio: http://www.fastcoexist.com/3056129/this-house-costs-just-20000-but-its-nicer-than-yours/16

(There must be a word to describe that “it’d be a mighty shame if this doesn’t already exist”.)

fasihsignal liked Dave's thought #6075 on TIL
8 years, 6 months ago

Thoughts by this user that have been liked by others.

1

With all this Firebird on my mind [1], one thing led to another, and I was hit by all of Stravinsky’s Rite of Spring with François-Xavier Roth and Les Siècles on BBC. 💀.

And finished Miyazaki’s acclaimed 風立ちぬ too. Been a heavy night.

[1] Benjamin Carlson also gutsily compared the finale of Firebird to a Paul van Dyk beat. Everything is better with Firebird. Rite of Spring, not so much.