qlc v1.0.2 Qlc

Summary

Functions

variable binding list to erlang_binding list

create qlc cursor from qlc_handle (create processes)

delete qlc cursor (kill processes)

eval qlc_handle

erlang ast with binding variables to qlc_handle

string to erlang ast

fold qlc_handle with accumulator

optoin list to record(:qlc_opt)

string to qlc_handle with variable bindings

Types

bindings :: [any]
error_info :: :erl_parse.error_info
expr :: :erl_parse.abstract_expr
qlc_lc :: any
qlc_opt :: [any] | tuple

Functions

bind(a)
bind(list, b)

Specs

bind([Keyword], bindings) :: bindings

variable binding list to erlang_binding list

cursor(qh)

Specs

create qlc cursor from qlc_handle (create processes)

delete_cursor(qc)

Specs

delete_cursor(Qlc.Cursor) :: :ok

delete qlc cursor (kill processes)

e(qh)

Specs

e(query_handle) :: list

eval qlc_handle

expr_to_handle(expr, bind, opt)

Specs

expr_to_handle([expr], bindings, qlc_opt) :: query_handle

erlang ast with binding variables to qlc_handle

exprs(str)

Specs

exprs(String.t) :: expr | no_return

string to erlang ast

fold(qh, a, f, option \\ [])

Specs

fold(query_handle, any, (any, any -> any), [any]) :: any

fold qlc_handle with accumulator

example

iex> require Qlc
iex> list = [a: 1,b: 2,c: 3]
iex> qlc_handle = Qlc.q("[X || X = {K,V} <- L, K =/= Item]",
...>        [L: list, Item: :b])
...> Qlc.fold(qlc_handle, [], fn({k,v}, acc) ->
...>   [{v, k}|acc]
...> end)
[{3, :c}, {1, :a}]
options(opt, keys, acc)

Specs

options(list, list, qlc_opt) :: qlc_opt

optoin list to record(:qlc_opt)

string_to_handle(str, bindings, opt \\ [])

Specs

string_to_handle(String.t, bindings, list) :: query_handle

string to qlc_handle with variable bindings

Macros

q(string, bindings, opt \\ [])

string to qlc_handle with variable bindings (string must be literal, because its a macro.)

qlc expression string

syntax

[Expression || Qualifier1, Qualifier2, ...]

Expression :: arbitary Erlang term (the template)

Qualifier :: Filter or Generators

Fiilter :: Erlang expressions returning bool()

Generator :: Pattern <- ListExpression

ListExpression :: Qlc_handle or list()

Qlc_handle :: returned from Qlc.table/2, Qlc.sort/2, Qlc.keysort/2
                          Qlc.q/2, Qlc.string_to_handle/2

example

iex> require Qlc
iex> list = [a: 1,b: 2,c: 3]
iex> qlc_handle = Qlc.q("[X || X = {K,V} <- L, K =/= Item]",
...>        [L: list, Item: :b])
...> Qlc.e(qlc_handle)
[a: 1, c: 3]
...> Qlc.q("[X || X = {K, V} <- L, K =:= Item]",
...>       [L: qlc_handle, Item: :c]) |>
...> Qlc.e
[c: 3]
qlc_handle(args \\ [])
qlc_handle(record, args)
qlc_lc(args \\ [])
qlc_lc(record, args)
qlc_opt(args \\ [])
qlc_opt(record, args)