All Projects → pzp1997 → assoc-list

pzp1997 / assoc-list

Licence: BSD-3-Clause license
Dictionary with custom keys implemented using association lists

Programming Languages

elm
856 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to assoc-list

ieml-language
The IEML language database. A git database containing the translations for IEML expressions: USL (Uniform Semantic Locator)
Stars: ✭ 17 (-43.33%)
Mutual labels:  dictionary
Manji
Manji is a mobile application built to help people learning Japanese learn about Kanji.
Stars: ✭ 142 (+373.33%)
Mutual labels:  dictionary
Diccionario-JavaScript
project-dictionary.gitbooks.io/diccionario-javascript/content/
Stars: ✭ 13 (-56.67%)
Mutual labels:  dictionary
JADA
JADA - Just Another Dictionary App
Stars: ✭ 20 (-33.33%)
Mutual labels:  dictionary
nihongo
Japanese Dictionary
Stars: ✭ 77 (+156.67%)
Mutual labels:  dictionary
dictionary
Project that tries to help you learn English.📕
Stars: ✭ 28 (-6.67%)
Mutual labels:  dictionary
pali
Pāḷi Tipiṭaka and Pāḷi Dictionaries
Stars: ✭ 20 (-33.33%)
Mutual labels:  dictionary
vocabulary-titan
Chatbot for searching vocabulary on mainstream dictionaries
Stars: ✭ 70 (+133.33%)
Mutual labels:  dictionary
French-Dictionary
CSV files containing all french adjectives, adverbs, conjunctions, determiners, nouns, prepositions, pronouns, verbs and their gender, types and conjugations
Stars: ✭ 74 (+146.67%)
Mutual labels:  dictionary
wikdict-gen
Generation of bilingual dictionaries from Wiktionary/dbnary data for the WikDict project
Stars: ✭ 32 (+6.67%)
Mutual labels:  dictionary
flask-mdict
Flask Mdict Server. Query word online with MDICT dictionary
Stars: ✭ 62 (+106.67%)
Mutual labels:  dictionary
Britfone
British English pronunciation dictionary
Stars: ✭ 66 (+120%)
Mutual labels:  dictionary
MagicDict
Fastest and Smallest Data structure for Querying valid english words.
Stars: ✭ 24 (-20%)
Mutual labels:  dictionary
LSTM-sentiment-analysis
LSTM sentiment analysis. Please look at my another repo for SVM and Naive algorithem
Stars: ✭ 19 (-36.67%)
Mutual labels:  dictionary
new-word-tab
A browser extension to learn a new word per new tab
Stars: ✭ 30 (+0%)
Mutual labels:  dictionary
AppleScript-IDEA
AppleScript support for IntelliJ IDEs
Stars: ✭ 21 (-30%)
Mutual labels:  dictionary
js-mdict
*.mdx/*.mdd interpreter js implements
Stars: ✭ 91 (+203.33%)
Mutual labels:  dictionary
mw-thesaurus.el
Merriam-Webster Thesaurus in Emacs
Stars: ✭ 84 (+180%)
Mutual labels:  dictionary
Jotoba
A free online, self-hostable, multilang Japanese dictionary.
Stars: ✭ 87 (+190%)
Mutual labels:  dictionary
programminginpython.com
This repo consists code of all the programs discussed at programminginpython.com website
Stars: ✭ 60 (+100%)
Mutual labels:  dictionary

Association lists

Build Status

An association list is a list of tuples that map unique keys to values. The keys can be of any type (so long as it has a reasonable definition for equality). This includes pretty much everything except for functions and things that contain functions.

Usage

This library is intended to be used as a drop-in replacement for the Dict module in elm/core. You might use it like so,

import AssocList as Dict exposing (Dict)

type Character
    = Ariel
    | Simba
    | Mufasa
    | Woody

type Movie
    = LittleMermaid
    | LionKing
    | ToyStory

characterToMovie : Dict Character Movie
characterToMovie =
    Dict.fromList
        [ ( Ariel, LittleMermaid )
        , ( Simba, LionKing )
        , ( Mufasa, LionKing )
        , ( Woody, ToyStory )
        ]

Dict.get Simba characterToMovie --> Just LionKing

(Note the use of a custom type as the dictionary key, which is not possible with the Dict module in elm/core!)

Performance

Since this library does not require your keys to be comparable, some operations are asymptotically slower than those in the Dict module in elm/core. The good news is that if you are working with small-ish dictionaries, this is likely not a problem. Furthermore, the bottleneck point in most Elm programs is DOM manipulation, so slower data structure operations are unlikely to cause a noticeable difference in how your app performs. For a detailed comparison of the performance characteristics of the two implementations, see Performance.md.

Comparison to existing work

Dictionary with non-comparable keys

All the existing libraries that I have found that attempt to solve the dictionary with non-comparable keys problem suffer from at least one of the following issues:

  1. stores a function for converting keys to comparable within the data structure itself

    • can cause runtime errors should you ever use the == operator to compare the structures
    • makes serialization trickier (for this reason, conventional wisdom states that you should "never put functions in your Model or Msg types")
    • see this Discourse post and this Elm Discuss thread for more information
  2. does not provide full type-level safety against operating on two dictionaries with different comparators, e.g. union (singleton identity 0 'a') (singleton (\x -> x + 1) 1 'b')

Here is a detailed analysis of all the relevant libraries I could find:

turboMaCk/any-dict

  • suffers from problems (1) and (2)

rtfeldman/elm-sorter-experiment

  • suffers from problem (1)

jjant/elm-dict

  • similar to problem (1), the data structure itself is actually a function
  • does not support the entire Dict API from elm/core

eeue56/elm-all-dict

  • suffers from problems (1) and (2)
  • some parts of the library rely on Kernel code, making it non-trivial to update to 0.19

robertjlooby/elm-generic-dict

  • suffers from problem (1)
  • has not been updated to 0.19 as of time of writing

Ordered dictionary

Although not the primary problem that this library aims to solve, assoc-list can also be used as an ordered dictionary, i.e. a dictionary that keeps track of the order in which entries were inserted. This functionality is similar to the following libraries:

y0hy0h/ordered-containers

  • requires the keys to be comparable

wittjosiah/elm-ordered-dict

  • requires the keys to be comparable
  • has not been updated to 0.19 as of time of writing

rnons/ordered-containers

  • requires the keys to be comparable
  • has not been updated to 0.19 as of time of writing

eliaslfox/orderedmap

  • requires the keys to be comparable
  • has not been updated to 0.19 as of time of writing
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].