2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,7 +1,14 @@
A function is a body of code that returns a value.
The value returned may depend on arguments provided to the function.
;Task:
Write a definition of a function called "multiply" that takes two arguments and returns their product.
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
See also:[[Function prototype]]
;Related task:
*   [[Function prototype]]
<br><br>

View file

@ -0,0 +1,8 @@
MULTIPLY: STX MULN ; 6502 has no "acc += xreg" instruction,
TXA ; so use a memory address
MULLOOP: DEY
CLC ; remember to clear the carry flag before
ADC MULN ; doing addition or subtraction
CPY #$01
BNE MULLOOP
RTS

View file

@ -0,0 +1,7 @@
// One-liner
fun multiply(a: Int, b: Int) = a * b
// Proper function definition
fun multiplyProper(a: Int, b: Int): Int {
return a * b
}

View file

@ -0,0 +1 @@
multiply:= (a, b) -> a * b;

View file

@ -1 +1 @@
@list.grep( -> $obj { $obj.substr(0,1).lc.match(/<[0..9 a..f]>/) )
@list.grep( -> $obj { $obj.substr(0,1).lc.match(/<[0..9 a..f]>/) } )

View file

@ -0,0 +1,4 @@
float multiply(float x, float y)
{
return x * y;
}

View file

@ -0,0 +1,3 @@
proc multiply( a, b );
return a * b;
end proc;

View file

@ -0,0 +1,9 @@
BEGIN
INTEGER PROCEDURE multiply(x, y);
INTEGER x, y;
BEGIN
multiply := x * y
END;
Outint(multiply(7,8), 2);
Outimage
END

View file

@ -1,2 +1,2 @@
@(do (defun mult (a b) (* a b))
(put-line `3 * 4 = @(mult 3 4)`))
(defun mult (a b) (* a b))
(put-line `3 * 4 = @(mult 3 4)`)