qlc v1.0.3 Qlc View Source

Link to this section 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. string may be literal or variable. If string is variable or function call, then expanding to string_to_handle/3 automatically

string to qlc_handle with variable bindings

Link to this section Types

Link to this section Functions

variable binding list to erlang_binding list

create qlc cursor from qlc_handle (create processes)

Link to this function

delete_cursor(qc) View Source
delete_cursor(Qlc.Cursor) :: :ok

delete qlc cursor (kill processes)

eval qlc_handle

Link to this function

expr_to_handle(expr, bind, opt) View Source
expr_to_handle(expr(), binding_struct(), qlc_opt()) ::
  query_handle() | {:qlc_handle, tuple()}

erlang ast with binding variables to qlc_handle

string to erlang ast

Link to this function

fold(qh, a, f, option \\ []) View Source
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}]
Link to this function

options(opt, keys, acc) View Source
options(list(), list(), qlc_opt()) :: qlc_opt()

optoin list to record(:qlc_opt)

Link to this macro

q(string, bindings, opt \\ []) View Source (macro)

string to qlc_handle with variable bindings. string may be literal or variable. If string is variable or function call, then expanding to string_to_handle/3 automatically.

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]
...> query_string = "[X || X = {K, V} <- L, K =:= Item]"
...> bindings = [L: list, Item: :b]
...> Qlc.q(query_string, bindings) |> Qlc.e()
[b: 2]
Link to this macro

qlc_handle(args \\ []) View Source (macro)

Link to this macro

qlc_handle(record, args) View Source (macro)

Link to this macro

qlc_lc(args \\ []) View Source (macro)

Link to this macro

qlc_lc(record, args) View Source (macro)

Link to this macro

qlc_opt(args \\ []) View Source (macro)

Link to this macro

qlc_opt(record, args) View Source (macro)

Link to this function

string_to_handle(str, bindings, opt \\ []) View Source
string_to_handle(String.t(), binding_struct(), list()) ::
  query_handle()
  | {:error, :qlc,
     {non_neg_integer() | {non_neg_integer(), pos_integer()}, atom(), any()}}

string to qlc_handle with variable bindings