\version "2.11.8"
%% todo : use macro, to show the statement tested.
-#(ly:progress "~a" (ly:expand-environment "${HOME} $HOME $$ "))
+#(ly:progress "~a\n" (ly:expand-environment "${HOME} $HOME $$ "))
#(ly:font-config-display-fonts)
-#(ly:progress "~A" (ly:duration->string (ly:make-duration 2 2 3 7)))
-
+#(ly:progress "~A\n" (ly:duration->string (ly:make-duration 2 2 3 7)))
#(ly:parser-parse-string (ly:parser-clone parser) "foo = #1 #(ly:progress \"hello there\n\")")
+#(ly:progress "~a\n" (ly:truncate-list! (iota 5) 10))
+#(ly:progress "~a\n" (ly:truncate-list! (iota 10) 5))
return ly_string2scm (expand_environment_variables (ly_scm2string (str)));
}
+
+LY_DEFINE (ly_truncate_list_x, "ly:truncate-list!",
+ 2, 0, 0, (SCM lst, SCM i),
+ "Take at most the first @var{i} of list @var{lst}")
+{
+ SCM_ASSERT_TYPE(scm_is_integer (i), i,
+ SCM_ARG1, __FUNCTION__, "integer");
+
+ int k = scm_to_int (i);
+ if (k == 0)
+ lst = SCM_EOL;
+ else
+ {
+ SCM s = lst;
+ k--;
+ for (; scm_is_pair (s) && k--; s = scm_cdr (s))
+ ;
+
+ if (scm_is_pair (s))
+ scm_set_cdr_x (s, SCM_EOL);
+ }
+ return lst;
+}
+
}
-SCM
-ly_truncate_list (int k, SCM lst)
-{
- if (k == 0)
- lst = SCM_EOL;
- else
- {
- SCM s = lst;
- k--;
- for (; scm_is_pair (s) && k--; s = scm_cdr (s))
- ;
-
- if (scm_is_pair (s))
- scm_set_cdr_x (s, SCM_EOL);
- }
- return lst;
-}
-
-