【Hacker News搬运】一切都只是功能:SICP和David Beazley的见解
-
Title: Everything Is Just Functions: Insights from SICP and David Beazley
一切都只是功能:SICP和David Beazley的见解
Text:
Url: https://ezzeriesa.notion.site/1-week-with-David-Beazley-and-SICP-4c440389cf1e43f48fe67c969967f655#58ee6b0435b24e26bd624b33ffed94df
由于我是一个AI,我无法直接访问或抓取互联网上的内容。不过,我可以提供一些指导,告诉你如果想要使用JinaReader这样的工具来抓取和分析网页内容,以及如何处理非中文内容。 1. **抓取内容**: - 使用JinaReader或其他网页抓取工具,你可以将提供的URL输入到工具中。 - 工具会访问该网页,并获取HTML内容。 2. **分析内容**: - 一旦获取了HTML内容,你可以使用JinaReader中的自然语言处理(NLP)功能来分析文本。 - 你可以使用分词、词性标注、命名实体识别等NLP技术来分析文本。 3. **翻译非中文内容**: - 如果抓取的内容包含非中文文本,你可以使用在线翻译服务或集成翻译API(如Google Translate API)来将这些文本翻译成中文。 - 在JinaReader中,你可能需要编写一些脚本来调用翻译API,并将翻译后的文本添加到原始内容中。 以下是一个简化的例子,说明如何使用Python和翻译API来翻译非中文内容: ```python from googletrans import Translator # 创建翻译器对象 translator = Translator() # 要翻译的文本 text_to_translate = "This is an English sentence." # 翻译文本 translation = translator.translate(text_to_translate, dest='zh-cn') # 打印翻译后的文本 print(translation.text)
请注意,上述代码使用了
googletrans
库,这是一个简单的翻译API封装。在实际应用中,你可能需要处理HTTP请求、错误处理、API密钥管理等。以下是一个更完整的流程,概述了如何使用JinaReader和其他工具来抓取、分析和翻译内容:
- 使用JinaReader抓取网页内容。
- 分析抓取的HTML内容,提取文本。
- 检测文本中的语言。
- 如果检测到非中文语言,使用翻译API将文本翻译成中文。
- 将翻译后的文本进行进一步的分析或总结。
- 输出分析结果或总结。
由于我无法直接访问提供的链接,我无法为你提供具体的分析结果或翻译。如果你需要这些功能,你可能需要自己实现上述步骤或使用现成的服务。
## Post by: kurinikku ### Comments: **emmanueloga_**: Warning: Diving into SCIP/Lisp/Scheme can transform how you think about programming... food for thought is always welcomed! But applying those ideas wholesale to OOP codebases often backfires or gets pushback from teammates. Languages handle paradigms differently, and going against the grain usually leads to worse code.<p>Example: After Lisp, you might replace every for loop with forEach or chain everything through map/reduce. But unless you’re working in a language that fully embraces functional programming, this approach can hurt both readability and performance.<p>At the end of the day, it’s grounding to remember there’s mutable memory and a CPU processing the code. These days, I find data-oriented design and “mechanical sympathy” (aligning code with hardware realities) more practical day-to-day than more abstract concepts like Church numerals. > **emmanueloga_**: 警告:潜入SCIP;Lisp;Scheme可以改变你对编程的看法。。。思考的食物总是受欢迎的!但是,将这些想法大规模应用于OOP代码库往往会适得其反或受到队友的抵制。语言处理范式的方式不同,违反规则通常会导致更糟糕的代码<p> 示例:在Lisp之后,您可以将every for循环替换为forEach,或者通过map链接所有内容;减少。但是,除非你使用的语言完全包含函数式编程,否则这种方法可能会损害可读性和性能<p> 最后,记住有可变内存和处理代码的CPU是基础。如今,我发现面向数据的设计和“机械同情”(将代码与硬件现实对齐)比教堂数字等更抽象的概念更实用。 **marvinborner**: They give a nice introduction to encoding state as pure functions. In fact, there are many more purely functional encodings for all kinds of data like trees, integers, sum/product types, images, monads, ...<p>The encodings can be a bit confusing, but really elegant and tiny at the same time. Take for example a functional implementation of the Maybe monad in javascript:<p><pre><code> Nothing = nothing => just => nothing Just = v => nothing => just => just(v) pure = Just bind = mx => f => mx(mx)(f) evalMaybe = maybe => maybe("Nothing")(v => "Just " + v) console.log(evalMaybe(bind(Nothing)(n => pure(n + 1)))) // Nothing console.log(evalMaybe(bind(Just(42))(n => pure(n + 1)))) // Just 43</code></pre> > **marvinborner**: 它们很好地介绍了将状态编码为纯函数。事实上,对于所有类型的数据,如树、整数、和,还有更多纯粹的函数编码;产品类型、图像、单子等<p> 编码可能有点令人困惑,但同时非常优雅和小巧。以javascript中Maybe monad的函数实现为例:<p><pre><code>Nothing=Nothing=>;just=>;没有什么Just=v=>;无=>;just=>;只是(v)纯=公正bind=mx=>;f=>;mx(mx)(f)evalMaybe=可能=>;也许(“无”)(v=>;只是";+v)console.log(evalMaybe(绑定(无)(n=>纯(n+1)))/;没有什么console.log(evalMaybe(bind(Just(42))(n=>纯(n+1)))/;只有43个</code></pre> **zahlman**: I've watched the actual SICP lectures before (the 1986 recordings on MIT OCW). They're often praised for the information density, but it actually still wastes a lot of time listening to students' Q&A, the lecturers drawing the class' attention to various attempts at "multimedia" presentation in the classroom, simply not having the entire lesson plan worked out in advance (i.e., not being able to <i>preempt</i> the Q&A) etc. For that matter, the sheer amount of time spent on <i>writing things on a chalkboard</i> really adds up.<p>And of course the order of the material could be debated and rearranged countless ways. One of my future planned projects is to do my own video series presenting the material according to my own sensibilities.<p>It's nice to hear that the course apparently still stays true to its roots while using more current languages like Python. Python is designed as a pragmatic, multi-paradigm language and I think people often don't give it enough credit for its expressive power using FP idioms (if not with complete purity). > **zahlman**: 我;我以前看过SICP的讲座(1986年麻省理工开放式课程的录音)。他们;人们经常称赞它的信息密度,但实际上它仍然浪费了很多时间听学生说话;Q&;A、 讲师们在课堂上画画;注意各种尝试";“多媒体”;在课堂上进行演示,只是没有提前制定整个课程计划(即无法抢先问答)等。就这一点而言,在黑板上写东西所花费的时间真的加起来了<p> 当然,材料的顺序可以通过无数种方式进行辩论和重新排列。我未来计划的项目之一是制作自己的视频系列,根据自己的感受呈现材料<p> 它;很高兴听到这门课程在使用Python等更流行的语言的同时,显然仍然忠于其根源。Python被设计为一种实用的、多范式的语言,我认为人们通常不会这样做;使用FP习语(如果不是完全纯粹的话)来表达它的能力,这是不够的。 **liontwist**: The cons/car/cdr implementation as lambda was magical the first time I saw it. But it just shows that the language runtime must implement key/value dictionaries and you are able to borrow that implementation to make other data structures. > **liontwist**: 缺点;汽车;cdr作为lambda的实现在我第一次看到时很神奇。但它只是表明语言运行库必须实现key/;值字典,您可以借用该实现来制作其他数据结构。 **pinerd3**: Just fyi (perhaps @dang) this jumps to the Postscript of the blog post due to the anchor/hash in the URL. I was a bit confused initially. > **pinerd3**: 请注意(可能是@dang),由于锚点,这会跳转到博客文章的Postscript;URL中的哈希值。起初我有点困惑。