Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/std
Submodule std updated 5 files
+22 −12 List.ark
+0 −1 Macros.ark
+14 −28 Math.ark
+2 −3 Range.ark
+13 −10 String.ark
4 changes: 2 additions & 2 deletions src/arkscript/Formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ std::string Formatter::formatCondition(const Node& node, const std::size_t inden
const Node then_node = node.constList()[2];

bool cond_on_newline = false;
std::string formatted_cond = format(cond_node, indent + 1, false);
const std::string formatted_cond = format(cond_node, indent + 1, false);
if (formatted_cond.find('\n') != std::string::npos)
cond_on_newline = true;

std::string if_cond_formatted = fmt::format(
"({}if{}{}",
is_macro ? "$" : "",
cond_on_newline ? "\n" : " ",
formatted_cond);
cond_on_newline ? format(cond_node, indent + 1, true) : formatted_cond);

const bool split_then_newline = shouldSplitOnNewline(then_node) || isBeginBlock(then_node);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(let permutations (fun ((ref _L) _r _f) {
(let _len (len _L))
(if (and (<= _r _len) (> _r 0))
{
(mut _indices (iota 0 _r))
(if (!= stopIteration (_f (select _L _indices)))
{
(mut _continue true)
(let _reversed_indices (reverse _indices))
(while _continue {
(mut _i nil)
(if
(forEach
_reversed_indices
(fun (_val) {
(set _i _val)
(if (!= (@ _indices _i) (+ _i _len (* -1 _r))) stopIteration) }))
{
(@= _indices _i (+ 1 (@ _indices _i)))
(mut _j (+ 1 _i))
(while (< _j _r) {
(@= _indices _j (+ 1 (@ _indices (- _j 1))))
(set _j (+ 1 _j)) })
(if (= stopIteration (_f (select _L _indices)))
(set _continue false)) }
(set _continue false)) }) }) }) }))
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(let permutations (fun ((ref _L) _r _f) {
(let _len (len _L))
(if (and (<= _r _len) (> _r 0))
{
(mut _indices (iota 0 _r))
(if (!= stopIteration (_f (select _L _indices)))
{
(mut _continue true)
(let _reversed_indices (reverse _indices))
(while _continue {
(mut _i nil)
(if
(forEach
_reversed_indices
(fun (_val) {
(set _i _val)
(if (!= (@ _indices _i) (+ _i _len (* -1 _r))) stopIteration) }))
{
(@= _indices _i (+ 1 (@ _indices _i)))
(mut _j (+ 1 _i))
(while (< _j _r) {
(@= _indices _j (+ 1 (@ _indices (- _j 1))))
(set _j (+ 1 _j)) })
(if (= stopIteration (_f (select _L _indices)))
(set _continue false)) }
(set _continue false)) }) }) }) }))
10 changes: 10 additions & 0 deletions tools/ark_format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

for f in *.ark; do
arkscript -f "$f"
if [[ $? == 1 ]]; then
echo "Formatted $f"
fi
done

echo "All files in $(pwd) are correctly formatted!"
Loading