June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,17 +1,7 @@
void
output_date(date d)
{
o_integer(d_year(d));
o_byte('/');
o_finteger(2, d_y_month(d));
o_byte('/');
o_finteger(2, d_m_day(d));
}
void
output_real(real x)
{
o_real(8, x);
o_form("~%//f2/%//f2/", d.year, d.y_month, d.m_day);
}
void
@ -20,33 +10,23 @@ g(...)
integer i;
record r;
r_put(r, "integer", o_integer);
r_put(r, "real", output_real);
r_put(r, "text", o_text);
r_put(r, "date", output_date);
r["integer"] = o_integer;
r["real"] = o_;
r["text"] = o_text;
r["date"] = output_date;
i = 0;
while (i < count()) {
call(r_query(r, __type($i)), $i);
o_byte('\n');
i += 1;
r[__type($i)]($i);
o_byte('\n');
i += 1;
}
}
date
now(void)
{
date d;
d_now(d);
return d;
}
integer
main(void)
{
g("X.1", 707, .5, now());
g("X.1", 707, .5, date().now);
return 0;
}

View file

@ -0,0 +1,13 @@
@echo off
:_main
call:_variadicfunc arg1 "arg 2" arg-3
pause>nul
:_variadicfunc
setlocal
for %%i in (%*) do echo %%~i
exit /b
:: Note: if _variadicfunc was called from cmd.exe with arguments parsed to it, it would only need to contain:
:: @for %%i in (%*) do echo %%i

View file

@ -3,7 +3,7 @@ import extensions.
extension variadicOp
{
generic printAll args:list
generic printAll(object<> list)
[
list forEach(:v)
[

View file

@ -0,0 +1 @@
MACRO: variadic-print ( n -- quot ) [ print ] n*quot ;

View file

@ -0,0 +1,13 @@
IN: scratchpad "apple" "banana" "cucumber"
--- Data stack:
"apple"
"banana"
"cucumber"
IN: scratchpad 2 variadic-print
cucumber
banana
--- Data stack:
"apple"

View file

@ -0,0 +1,26 @@
# Project : Variadic function
# Date : 2017/11/13
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
sum([1,2])
sum([1,2,3])
nums = [1,2,3,4]
sum(nums)
func sum(nums)
total = 0
for num = 1 to len(nums)
total = total + num
next
showarray(nums)
see " " + total + nl
func showarray(vect)
see "["
svect = ""
for n = 1 to len(vect)
svect = svect + vect[n] + " "
next
svect = left(svect, len(svect) - 1)
see "" + svect + "]"