mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
core: split Char.prn and Char.str (only prn should add slashes
This commit is contained in:
parent
c1a9bb6ac1
commit
42918e3ef6
@ -123,6 +123,7 @@
|
||||
|
||||
(defmodule Char
|
||||
(register str (Fn [Char] String))
|
||||
(register prn (Fn [Char] String))
|
||||
(register format (Fn [&String Char] String))
|
||||
)
|
||||
|
||||
@ -131,5 +132,4 @@
|
||||
(defmodule Float (defn prn [x] (Float.str x)))
|
||||
(defmodule Double (defn prn [x] (Double.str x)))
|
||||
(defmodule Bool (defn prn [x] (Bool.str x)))
|
||||
(defmodule Char (defn prn [x] (Char.str x)))
|
||||
(defmodule Array (defn prn [x] (Array.str x)))
|
||||
|
@ -120,6 +120,12 @@ String Bool_format(String* str, bool b) {
|
||||
}
|
||||
|
||||
String Char_str(char c) {
|
||||
String buffer = CARP_MALLOC(2);
|
||||
snprintf(buffer, 2, "%c", c);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
String Char_prn(char c) {
|
||||
String buffer = CARP_MALLOC(3);
|
||||
snprintf(buffer, 3, "\\%c", c);
|
||||
return buffer;
|
||||
|
@ -12,7 +12,6 @@
|
||||
*** The error reporting in Eval is a mess, must make it possible to return errors with correct location for all kinds of errors.
|
||||
*** This hangs the repl: `(expand '(load-and-use SDL))`
|
||||
*** def needs to come before hidden, or the compiler chokes
|
||||
*** str and prn both add slashes for Char
|
||||
* Big Language Features
|
||||
** 0.4
|
||||
*** Doc strings and type annotations.
|
||||
|
@ -1 +1 @@
|
||||
<html><head><meta charset="UTF-8"><meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"><link href="carp_style.css" rel="stylesheet"></head><body><div class="content"><div class="logo"><a href="http://github.com/carp-lang/Carp"><img src="logo.png"></a><div class="title">core</div><div class="index"><ul><li><a href="Dynamic.html">Dynamic</a></li><li><a href="Int.html">Int</a></li><li><a href="Long.html">Long</a></li><li><a href="Bool.html">Bool</a></li><li><a href="Float.html">Float</a></li><li><a href="Double.html">Double</a></li><li><a href="Vector2.html">Vector2</a></li><li><a href="V2.html">V2</a></li><li><a href="Vector3.html">Vector3</a></li><li><a href="V3.html">V3</a></li><li><a href="VectorN.html">VectorN</a></li><li><a href="VN.html">VN</a></li><li><a href="Geometry.html">Geometry</a></li><li><a href="Statistics.html">Statistics</a></li><li><a href="String.html">String</a></li><li><a href="Char.html">Char</a></li><li><a href="Pattern.html">Pattern</a></li><li><a href="Array.html">Array</a></li><li><a href="IO.html">IO</a></li><li><a href="System.html">System</a></li><li><a href="Debug.html">Debug</a></li><li><a href="Test.html">Test</a></li><li><a href="Bench.html">Bench</a></li></ul></div></div><h1>Char</h1><div class="binder"><a href="#/=" class="anchor"><h3 id="/=">/=</h3></a><div class="description">defn</div><p class="sig">(λ [Char, Char] Bool)</p><p class="doc"></p></div><div class="binder"><a href="#=" class="anchor"><h3 id="=">=</h3></a><div class="description">external</div><p class="sig">(λ [Char, Char] Bool)</p><p class="doc"></p></div><div class="binder"><a href="#copy" class="anchor"><h3 id="copy">copy</h3></a><div class="description">external</div><p class="sig">(λ [&Char] Char)</p><p class="doc"></p></div><div class="binder"><a href="#format" class="anchor"><h3 id="format">format</h3></a><div class="description">external</div><p class="sig">(λ [&String, Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#from-int" class="anchor"><h3 id="from-int">from-int</h3></a><div class="description">external</div><p class="sig">(λ [Int] Char)</p><p class="doc"></p></div><div class="binder"><a href="#meaning" class="anchor"><h3 id="meaning">meaning</h3></a><div class="description">defn</div><p class="sig">(λ [&Char] Int)</p><p class="doc">Convert a numerical char into the appropriate number.</p></div><div class="binder"><a href="#prn" class="anchor"><h3 id="prn">prn</h3></a><div class="description">defn</div><p class="sig">(λ [Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#random" class="anchor"><h3 id="random">random</h3></a><div class="description">defn</div><p class="sig">(λ [] Char)</p><p class="doc"></p></div><div class="binder"><a href="#random-between" class="anchor"><h3 id="random-between">random-between</h3></a><div class="description">defn</div><p class="sig">(λ [Char, Char] Char)</p><p class="doc"></p></div><div class="binder"><a href="#str" class="anchor"><h3 id="str">str</h3></a><div class="description">external</div><p class="sig">(λ [Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#to-int" class="anchor"><h3 id="to-int">to-int</h3></a><div class="description">external</div><p class="sig">(λ [Char] Int)</p><p class="doc"></p></div></div></body></html>
|
||||
<html><head><meta charset="UTF-8"><meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"><link href="carp_style.css" rel="stylesheet"></head><body><div class="content"><div class="logo"><a href="http://github.com/carp-lang/Carp"><img src="logo.png"></a><div class="title">core</div><div class="index"><ul><li><a href="Dynamic.html">Dynamic</a></li><li><a href="Int.html">Int</a></li><li><a href="Long.html">Long</a></li><li><a href="Bool.html">Bool</a></li><li><a href="Float.html">Float</a></li><li><a href="Double.html">Double</a></li><li><a href="Vector2.html">Vector2</a></li><li><a href="V2.html">V2</a></li><li><a href="Vector3.html">Vector3</a></li><li><a href="V3.html">V3</a></li><li><a href="VectorN.html">VectorN</a></li><li><a href="VN.html">VN</a></li><li><a href="Geometry.html">Geometry</a></li><li><a href="Statistics.html">Statistics</a></li><li><a href="String.html">String</a></li><li><a href="Char.html">Char</a></li><li><a href="Pattern.html">Pattern</a></li><li><a href="Array.html">Array</a></li><li><a href="IO.html">IO</a></li><li><a href="System.html">System</a></li><li><a href="Debug.html">Debug</a></li><li><a href="Test.html">Test</a></li><li><a href="Bench.html">Bench</a></li></ul></div></div><h1>Char</h1><div class="binder"><a href="#/=" class="anchor"><h3 id="/=">/=</h3></a><div class="description">defn</div><p class="sig">(λ [Char, Char] Bool)</p><p class="doc"></p></div><div class="binder"><a href="#=" class="anchor"><h3 id="=">=</h3></a><div class="description">external</div><p class="sig">(λ [Char, Char] Bool)</p><p class="doc"></p></div><div class="binder"><a href="#copy" class="anchor"><h3 id="copy">copy</h3></a><div class="description">external</div><p class="sig">(λ [&Char] Char)</p><p class="doc"></p></div><div class="binder"><a href="#format" class="anchor"><h3 id="format">format</h3></a><div class="description">external</div><p class="sig">(λ [&String, Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#from-int" class="anchor"><h3 id="from-int">from-int</h3></a><div class="description">external</div><p class="sig">(λ [Int] Char)</p><p class="doc"></p></div><div class="binder"><a href="#meaning" class="anchor"><h3 id="meaning">meaning</h3></a><div class="description">defn</div><p class="sig">(λ [&Char] Int)</p><p class="doc">Convert a numerical char into the appropriate number.</p></div><div class="binder"><a href="#prn" class="anchor"><h3 id="prn">prn</h3></a><div class="description">external</div><p class="sig">(λ [Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#random" class="anchor"><h3 id="random">random</h3></a><div class="description">defn</div><p class="sig">(λ [] Char)</p><p class="doc"></p></div><div class="binder"><a href="#random-between" class="anchor"><h3 id="random-between">random-between</h3></a><div class="description">defn</div><p class="sig">(λ [Char, Char] Char)</p><p class="doc"></p></div><div class="binder"><a href="#str" class="anchor"><h3 id="str">str</h3></a><div class="description">external</div><p class="sig">(λ [Char] String)</p><p class="doc"></p></div><div class="binder"><a href="#to-int" class="anchor"><h3 id="to-int">to-int</h3></a><div class="description">external</div><p class="sig">(λ [Char] Int)</p><p class="doc"></p></div></div></body></html>
|
@ -20,7 +20,7 @@ Print!
|
||||
180
|
||||
[0 1 1 0 1 0 0 0 0 1]
|
||||
10000
|
||||
\#
|
||||
#
|
||||
-6000
|
||||
[1 4 9 16 25]
|
||||
ANSWER: 164
|
||||
|
Loading…
Reference in New Issue
Block a user