March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,40 @@
: f(x) fdup fsqrt fswap 3e f** 5e f* f+ ;
4e2 fconstant f-too-big
11 Constant #Elements
: float-array ( compile: n -- / run: n -- addr )
create
floats allot
does>
swap floats + ;
#Elements float-array vec
: get-it ( -- )
." Enter " #Elements . ." numbers:" cr
#Elements 0 DO
." > " pad 25 accept cr
pad swap >float 0= abort" Invalid Number"
i vec F!
LOOP ;
: reverse-it ( -- )
#Elements 2/ 0 DO
i vec F@ #Elements i - 1- vec F@
i vec F! #Elements i - 1- vec F!
LOOP ;
: do-it ( -- )
#Elements 0 DO
i vec F@ fdup f. [char] : emit space
f(x) fdup f-too-big f> IF
fdrop ." too large"
ELSE
f.
THEN cr
LOOP ;
: tpk ( -- )
get-it reverse-it do-it ;

View file

@ -23,11 +23,11 @@ int main (int argc, const char * argv[])
double userInput = 0.0;
printf("%s", "Please enter a number: ");
scanf("%lf", &userInput);
[input addObject: [NSNumber numberWithDouble: (double) userInput]];
[input addObject: @(userInput)];
}
for(int i = 10; i >= 0; i--) {
double x = [[input objectAtIndex: i] doubleValue];
double x = [input[i] doubleValue];
double y = f(x);
printf("f(%.2f) \t=\t", x);
if(y < 400.0) {

View file

@ -1,10 +1,10 @@
/*REXX program to implement the Trabb-Pardo-Knuth algorthm for N nums.*/
/*REXX program to implement the Trabb-Pardo-Knuth algorithm for N nums.*/
N=11 /*N is the number of numbers. */
maxValue=400 /*the maximum value f(x) can have*/
precDigs=200 /*compute with this many digits. */
showDigs=20 /*...but only show this many digs*/
numeric digits precDigs /*the number of digits precision.*/
prompt='enter' N "nunbers for the Trabb-Pardo-Knuth algorthm: (or Quit)"
prompt='enter' N "numbers for the Trabb-Pardo-Knuth algorithm: (or Quit)"
say ' _____ ' /*vinculum.*/
say 'function: ƒ(x) x + (5 * x^3)'
/*██████████████████████████████████████████████████████████████████████*/