Skip to content

Commit

Permalink
Docs generated from: feat: add Dynamic.String.to-array (#1382)
Browse files Browse the repository at this point in the history
* feat: add Dynamic.String.to-array

Adds a new dynamic function that converts a string to an array of
strings, one for each character in the string. In other words, it's the
same as Dynamic.String.to-list but the result is an array structure
instead of a list.

It's also significantly faster than to-list on large inputs. The current
implementation of Dynamic.String.to-list takes long to process large
inputs, presumably because of its recursive behavior and multiple calls
to cons (I'm currently investigating this) (e.g. use read-file then try
calling to-list, you may need to wait a while). Contrarily, to-array is
nearly instantaneous even when the input string is large. This is
because it leverages Haskell's `splitOn` directly, which, when given an
empty delimiter, (which is the case for the empty string), splits the
entire input sequence. Because "" is the empty list for a string in
Haskell's representation, calling split-on with "" results in the
splitting behavior. The output also includes the delimiting case, so we
drop it using cdr.

* test: add test for Dynamic.String.to-array
  • Loading branch information
carp-lang committed Feb 14, 2022
1 parent c481aee commit dad46be
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/Dynamic.String.html
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,26 @@ <h3 id="tail">

</p>
</div>
<div class="binder">
<a class="anchor" href="#to-array">
<h3 id="to-array">
to-array
</h3>
</a>
<div class="description">
dynamic
</div>
<p class="sig">
Dynamic
</p>
<pre class="args">
(to-array s)
</pre>
<p class="doc">
<p>Converts a string to an array of strings of each of its characters.</p>

</p>
</div>
<div class="binder">
<a class="anchor" href="#to-list">
<h3 id="to-list">
Expand Down

0 comments on commit dad46be

Please sign in to comment.