Skip to content

Instantly share code, notes, and snippets.

@adamdicarlo
Last active February 7, 2017 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdicarlo/d9608355dbe0092a8c506baeee79e07b to your computer and use it in GitHub Desktop.
Save adamdicarlo/d9608355dbe0092a8c506baeee79e07b to your computer and use it in GitHub Desktop.
Example of JavaScript generated from a bit of Elm code
var _adamdicarlo$elm_wordy$Wordy$eligibleWord = F2(
function (word, foundWords) {
return !A2(_elm_lang$core$List$member, word, foundWords);
});
var _adamdicarlo$elm_wordy$Wordy$findUnselectedLetter = F2(
function (letters, sought) {
var predicate = function (_p0) {
var _p1 = _p0;
return _elm_lang$core$Native_Utils.eq(_p1._0, sought) && (!_p1._1);
};
return A2(_elm_community$list_extra$List_Extra$findIndex, predicate, letters);
});
module Wordy exposing (main)
import List.Extra exposing (findIndex)
type Letter
= Letter Char Bool
eligibleWord : String -> List String -> Bool
eligibleWord word foundWords =
not (List.member word foundWords)
findUnselectedLetter : List Letter -> Char -> Maybe Int
findUnselectedLetter letters sought =
let
predicate (Letter ch selected) =
ch == sought && not selected
in
findIndex predicate letters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment