A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clojure.github.io/core.incubator/clojure.core.strint-api.html below:

Functions proposed for core inclusion 0.1.5 API documentation

API for clojure.core.strint -

Full namespace name:

clojure.core.strint Overview
Compile-time string interpolation for Clojure.

Public Variables and Functions
<<macro
Usage: (<< & strings)
Accepts one or more strings; emits a `str` invocation that concatenates
the string data and evaluated expressions contained within that argument.
Evaluation is controlled using ~{} and ~() forms. The former is used for
simple value replacement using clojure.core/str; the latter can be used to
embed the results of arbitrary function invocation into the produced string.

Examples:
  user=> (def v 30.5)
  #'user/v
  user=> (<< "This trial required ~{v}ml of solution.")
  "This trial required 30.5ml of solution."
  user=> (<< "There are ~(int v) days in November.")
  "There are 30 days in November."
  user=> (def m {:a [1 2 3]})
  #'user/m
  user=> (<< "The total for your order is $~(->> m :a (apply +)).")
  "The total for your order is $6."
  user=> (<< "Just split a long interpolated string up into ~(-> m :a (get 0)), "
           "~(-> m :a (get 1)), or even ~(-> m :a (get 2)) separate strings "
           "if you don't want a << expression to end up being e.g. ~(* 4 (int v)) "
           "columns wide.")
  "Just split a long interpolated string up into 1, 2, or even 3 separate strings if you don't want a << expression to end up being e.g. 120 columns wide."
  
Note that quotes surrounding string literals within ~() forms must be
escaped.
Source

Logo & site design by

Tom Hickey

.

Clojure auto-documentation system by Tom Faulhaber.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4