login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

And below an Aldor version of the Fibonacci function that resembles a definition done in Haskell.

fricas
(1) -> <aldor>
#include "axiom"
Z ==> Integer;
ZZ ==> Z -> Z;
-- Haskell
-- fiblist = 1 : 1 : (zipWith (+) fiblist (tail fiblist))
import from Z;
zipWith(op: (Z,Z)->Z, f: ZZ, g: ZZ)(x: Z): Z == op(f x, g x);
apply(z: Z, zz: ZZ)(x: Z): Z == if zero? x then z else zz(x-1);
tail(zz: ZZ)(x: Z): Z == zz(x+1);
fib(x: Z): Z == (1 1 zipWith(+, fib, tail fib)) x;</aldor>
fricas
Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1094142832394199181-25px001.as
      using Aldor compiler and options 
-O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra
      Use the system command )set compiler args to change these 
      options.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1094142832394199181-25px001.as", line 1: 
#include "axiom"
^
[L1 C1] #1 (Error) Could not open file `axiom'.
The )library system command was not called after compilation.

fricas
[fib n for n in 1..10]
There are no library operations named fib Use HyperDoc Browse or issue )what op fib to learn if there is any operation containing " fib " in its name. Cannot find a definition or applicable library operation named fib with argument type(s) PositiveInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. There are no library operations named fib Use HyperDoc Browse or issue )what op fib to learn if there is any operation containing " fib " in its name.
Cannot find a definition or applicable library operation named fib with argument type(s) PositiveInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

And here the same program written for Aldor without PanAxiom. Compile and run as follows: aldor -laldor -fx fib.as && ./fib

aldor
#include "aldor"
#include "aldorio"
Z ==> Integer; ZZ ==> Z -> Z;
import from Z; zipWith(op: (Z,Z)->Z, f: ZZ, g: ZZ)(x: Z): Z == op(f x, g x); apply(z: Z, zz: ZZ)(x: Z): Z == if zero? x then z else zz(x-1); tail(zz: ZZ)(x: Z): Z == zz(x+1);
fib(x: Z): Z == (1 1 zipWith(+, fib, tail fib)) x;
main(): () == { import from List Z; stdout << [fib n for n in 1..10] << newline; }
main();
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5940177716537504213-25px003.as
      using Aldor compiler and options 
-O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra
      Use the system command )set compiler args to change these 
      options.
   Compiling Lisp source code from file 
      ./5940177716537504213-25px003.lsp
   Issuing )library command for 5940177716537504213-25px003
   Reading #P"/var/aw/var/LatexWiki/5940177716537504213-25px003.asy"
   zipWith is now explicitly exposed in frame initial 
apply is now explicitly exposed in frame initial
tail is now explicitly exposed in frame initial
fib is now explicitly exposed in frame initial
main is now explicitly exposed in frame initial




  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: