Skip to content

Instantly share code, notes, and snippets.

@knutin
Forked from hukl/gist:1364952
Created November 21, 2011 17:32
Show Gist options
  • Select an option

  • Save knutin/1383321 to your computer and use it in GitHub Desktop.

Select an option

Save knutin/1383321 to your computer and use it in GitHub Desktop.
Ruby vs Erlang building URL query params for a GET request
-module(urljoin).
-compile([export_all]).
s() ->
lists:flatten(urljoin([{foo, "bar"}, {baz, "quux"}, {fubar, "ok"}])).
%%iolist_to_binary(urljoin([{foo, "bar"}, {baz, "quux"}, {fubar, "ok"}])).
urljoin([{K, V}]) ->
[atom_to_list(K), "=", V];
urljoin([{K, V} | T]) ->
[atom_to_list(K), $=, V, $& | urljoin(T)].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment