Awake Security will be livestreaming a periodic 1-on-1 teaching session on Twitch. The subject of this session will always be one of our engineers teaching another one of our engineers how to do accomplish a practical task in Haskell while remote attendees watch, comment, and ask questions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| This @lens@ tutorial targets Haskell beginners and assumes only basic | |
familiarity with Haskell. By the end of this tutorial you should: | |
* understand what problems the @lens@ library solves, | |
* know when it is appropriate to use the @lens@ library, | |
* be proficient in the most common @lens@ idioms, | |
* understand the drawbacks of using lenses, and: |
If programming is more than just a means of getting things done for you, then Common Lisp is for you!
Table of Contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
""" | |
文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
Parameters: | |
query (str): 検索クエリとして使用する文字列. | |
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |
One of my favorite comments on abstraction and parametricity ..
Parametricity can be thought of as the dual to abstraction. Where abstraction hides details about an implementation from the outside world, parametricity hides details about the outside world from an implementation.
When using OCaml as the implementation language, you abstract using ADTs (Abstract Data Types) and make your abstraction parametric using functors. And bind all of the algebras together using Modules.