Created
February 13, 2020 20:27
-
-
Save javipus/01bfba84ffbf2e18808de3a6838d49a0 to your computer and use it in GitHub Desktop.
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
% Prolog translation of the key functions in | |
% https://github.com/nearai/program_synthesis/blob/master/program_synthesis/algolisp/dataset/code_lisp.py | |
:- use_module(library(lists)). | |
:- use_module(library(dicts)). | |
% if ??? | |
% if(context, cond, then, else). | |
% get Index-th element in list - alias of nth0 from lists library | |
deref(Index, List, Elem) :- nth0(Index, List, Elem). | |
% set dict[key] to value - alias of put_dict from dicts library | |
dict_insert(Key, DictIn, Value, DictOut) :- put_dict(Key, DictIn, Value, DictOut). | |
% get head of list | |
head([H|_], H). | |
% integer range | |
% see https://stackoverflow.com/questions/7175258/prolog-generating-numbers-fitting-given-range | |
range_func(Lo, Lo, _). | |
range_func(Out, Lo, Hi) :- NewLo is Lo+1, range_func(Out, NewLo, Hi). | |
% reduce | |
% ??? | |
% partial | |
% ??? | |
% lambdas ??? | |
% div | |
div(X, Y, X_div_Y) :- X_div_Y is X/Y. | |
% slice | |
% could use this implementation or produce my own | |
% https://github.com/stassa/indexed_terms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment