TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Functional vs. Data-Driven Development: A Case-Study in Clojure and OCaml

6 点作者 gopiandcode3 个月前

1 comment

artikae2 个月前
assoc-in reminds me a lot of lenses in Haskell. I figure you could probably implement something like it using them. This is what I came up with:<p><pre><code> import Control.Lens baseLens --&gt; nextIndex = baseLens . ix nextIndex assocIn structure keyLens newValue = set keyLens newValue structure </code></pre> It works like so:<p><pre><code> setTo256 structure = assocIn structure (ix 0 --&gt; 0 --&gt; 0) 256 -- setTo256 [[[1]], [[2]]] returns [[[256]], [[2]]]</code></pre>