Changes in / [29038ef:e182ce3]


Ignore:
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r29038ef re182ce3  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jul  7 10:36:39 2017
    14 %% Update Count     : 2547
     13%% Last Modified On : Sun Jul  2 09:49:56 2017
     14%% Update Count     : 2503
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    24502450\end{cfa}
    24512451\\
    2452 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2452\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    245324531® ®2® ®3
    24542454\end{cfa}
    24552455&
    2456 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2456\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    245724571 2 3
    24582458\end{cfa}
     
    24612461The \CFA form has half the characters of the \CC form, and is similar to \Index*{Python} I/O with respect to implicit separators.
    24622462Similar simplification occurs for \Index{tuple} I/O, which prints all tuple values separated by ``\lstinline[showspaces=true]@, @''.
    2463 \begin{cfa}
    2464 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     2463\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2464[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    24652465sout | t1 | t2 | endl;                                  §\C{// print tuples}§
    24662466\end{cfa}
    2467 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2468 1®, ®2®, ®3 4®, ®5®, ®6
     2467\begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt]
     24681®, ®2®, ®3 3®, ®4®, ®5
    24692469\end{cfa}
    24702470Finally, \CFA uses the logical-or operator for I/O as it is the lowest-priority overloadable operator, other than assignment.
     
    24852485\\
    24862486&
    2487 \begin{cfa}[showspaces=true,aboveskip=0pt]
     2487\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    248824883 3 12 0 3 1 2
    24892489\end{cfa}
     
    25032503sout | 1 | 2 | 3 | endl;
    25042504\end{cfa}
    2505 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2505\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    250625061 2 3
    25072507\end{cfa}
     
    25702570\subsection{Manipulator}
    25712571
    2572 The following \CC-style \Index{manipulator}s and routines control implicit seperation.
     2572The following routines and \CC-style \Index{manipulator}s control implicit seperation.
    25732573\begin{enumerate}
    25742574\item
    2575 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sep}\index{manipulator!sep@©sep©}/\Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
     2575Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
    25762576The separator string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2577 \begin{cfa}[mathescape=off,belowskip=0pt]
     2577\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    25782578sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    2579 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;
     2579sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    25802580\end{cfa}
    25812581%$
     
    25842584\end{cfa}
    25852585%$
    2586 \begin{cfa}[belowskip=0pt]
     2586\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    25872587sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    25882588sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    25892589\end{cfa}
    2590 \begin{cfa}[showspaces=true,aboveskip=0pt]
     2590\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    259125911® ®2® ®3 ®" "®
    25922592\end{cfa}
    2593 ©sepGet© can be used to store a separator and then restore it:
    2594 \begin{cfa}[belowskip=0pt]
    2595 char store[®sepSize®];                                          §\C{// sepSize is the maximum separator size}§
    2596 strcpy( store, sepGet( sout ) );
    2597 sepSet( sout, "_" );
    2598 sout | 1 | 2 | 3 | endl;
    2599 \end{cfa}
    2600 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2601 1®_®2®_®3
    2602 \end{cfa}
    2603 \begin{cfa}[belowskip=0pt]
    2604 sepSet( sout, store );
    2605 sout | 1 | 2 | 3 | endl;
    2606 \end{cfa}
    2607 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2608 1® ®2® ®3
    2609 \end{cfa}
    2610 
    2611 \item
    2612 Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepTuple}\index{manipulator!sepTuple@©sepTuple©}/\Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
     2593
     2594\item
     2595Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
    26132596The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2614 \begin{cfa}[belowskip=0pt]
     2597\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    26152598sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    2616 sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;
    2617 \end{cfa}
    2618 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2619 1 2 3 4 5 6 ®" "®
    2620 \end{cfa}
    2621 \begin{cfa}[belowskip=0pt]
     2599sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2600\end{cfa}
     2601\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26021 2 3 4 ®" "®
     2603\end{cfa}
     2604\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    26222605sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    26232606sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
    26242607\end{cfa}
    2625 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2626 1, 2, 3 4, 5, 6 ®", "®
    2627 \end{cfa}
    2628 As for ©sepGet©, ©sepGetTuple© can be use to store a tuple separator and then restore it.
    2629 
    2630 \item
    2631 Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, \ie the seperator is adjusted with respect to all subsequent printed items.
    2632 \begin{cfa}[belowskip=0pt]
    2633 sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separator}§
    2634 \end{cfa}
    2635 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2608\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26091, 2, 3, 4 ®", "®
     2610\end{cfa}
     2611
     2612\item
     2613Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, \ie the seperator is adjusted only with respect to the next printed item.
     2614\begin{cfa}[mathescape=off,belowskip=0pt]
     2615sout | sepOn | 1 | 2 | 3 | sepOn | endl;        §\C{// separator at start/end of line}§
     2616\end{cfa}
     2617\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2618® ®1 2 3® ®
     2619\end{cfa}
     2620\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2621sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
     2622\end{cfa}
     2623\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     262412 3
     2625\end{cfa}
     2626The tuple separator also responses to being turned on and off.
     2627\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2628sout | sepOn | t1 | sepOff | t2 | endl;         §\C{// locally turn on/off implicit separation}§
     2629\end{cfa}
     2630\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2631, 1, 23, 4
     2632\end{cfa}
     2633Notice a tuple seperator starts the line because the next item is a tuple.
     2634
     2635\item
     2636Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, \ie the seperator is adjusted with respect to all subsequent printed items, unless locally adjusted.
     2637\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2638sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separation}§
     2639\end{cfa}
     2640\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    26362641123
    26372642\end{cfa}
    2638 \begin{cfa}[belowskip=0pt]
    2639 sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separator}§
     2643\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2644sout | 1 | ®sepOn® | 2 | 3 | endl;                      §\C{// locally turn on implicit separator}§
     2645\end{cfa}
     2646\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     26471® ®23
     2648\end{cfa}
     2649\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2650sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separation}§
    26402651\end{cfa}
    26412652\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    264226531 2 3
    26432654\end{cfa}
    2644 
    2645 \item
    2646 Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, \ie the seperator is adjusted only with respect to the next printed item.
    2647 \begin{cfa}[belowskip=0pt]
    2648 sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
    2649 \end{cfa}
    2650 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2651 12 3
    2652 \end{cfa}
    2653 \begin{cfa}[belowskip=0pt]
    2654 sout | sepDisable | 1 | sepOn | 2 | 3 | endl; §\C{// locally turn on implicit separator}§
    2655 \end{cfa}
    2656 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2657 1 23
    2658 \end{cfa}
    2659 The tuple separator also responses to being turned on and off.
    2660 \begin{cfa}[belowskip=0pt]
    2661 sout | t1 | sepOff | t2 | endl;                         §\C{// locally turn on/off implicit separator}§
    2662 \end{cfa}
    2663 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2664 1, 2, 34, 5, 6
    2665 \end{cfa}
    2666 ©sepOn© \emph{cannot} be used to start/end a line with a separator because separators do not appear at the start/end of a line;
    2667 use ©sep© to accomplish this functionality.
    2668 \begin{cfa}[belowskip=0pt]
    2669 sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       §\C{// sepOn does nothing at start/end of line}§
    2670 \end{cfa}
    2671 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2672 1 2 3
    2673 \end{cfa}
    2674 \begin{cfa}[belowskip=0pt]
    2675 sout | sep | 1 | 2 | 3 | sep | endl ;           §\C{// use sep to print separator at start/end of line}§
    2676 \end{cfa}
    2677 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2678 ® ®1 2 3® ®
    2679 \end{cfa}
    26802655\end{enumerate}
    26812656
    26822657\begin{comment}
    26832658#include <fstream>
    2684 #include <string.h>                                                                             // strcpy
    26852659
    26862660int main( void ) {
    26872661        int x = 1, y = 2, z = 3;
    26882662        sout | x | y | z | endl;
    2689         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     2663        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    26902664        sout | t1 | t2 | endl;                                          // print tuples
    26912665        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
     
    27012675
    27022676        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
    2703         sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;
     2677        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    27042678        sepSet( sout, " " );                                            // reset separator to " "
    27052679        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    27062680
    2707         char store[sepSize];
    2708         strcpy( store, sepGet( sout ) );
    2709         sepSet( sout, "_" );
    2710         sout | 1 | 2 | 3 | endl;
    2711         sepSet( sout, store );
    2712         sout | 1 | 2 | 3 | endl;
     2681        sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
     2682        sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
     2683
     2684        sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
     2685        sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
     2686        sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
    27132687
    27142688        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    2715         sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;
     2689        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    27162690        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    27172691        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    27182692
    2719         sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separator
    2720         sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separator
    2721        
    2722         sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn on implicit separator
    2723         sout | sepDisable | 1 | sepOn | 2 | 3 | endl; // globally turn off implicit separator
    2724         sout | sepEnable;
    2725         sout | t1 | sepOff | t2 | endl;                         // locally turn on/off implicit separator
    2726 
    2727         sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       // sepOn does nothing at start/end of line
    2728         sout | sep | 1 | 2 | 3 | sep | endl ;           // use sep to print separator at start/end of line
     2693        sout | t1 | t2 | endl;                                          // print tuple
     2694        sout | sepOn | t1 | sepOff | t2 | endl;         // locally turn on/off implicit separation
    27292695}
    27302696
     
    55825548// C unsafe allocation
    55835549extern "C" {
    5584 void * malloc( size_t size );§\indexc{memset}§
     5550void * mallac( size_t size );§\indexc{memset}§
    55855551void * calloc( size_t dim, size_t size );§\indexc{calloc}§
    55865552void * realloc( void * ptr, size_t size );§\indexc{realloc}§
  • src/libcfa/fstream

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:32:38 2017
    13 // Update Count     : 117
     12// Last Modified On : Sat Jul  1 16:37:53 2017
     13// Update Count     : 112
    1414//
    1515
    16 #pragma once
     16#ifndef __FSTREAM_H__
     17#define __FSTREAM_H__
    1718
    1819#include "iostream"
    1920
    20 enum { sepSize = 16 };
     21enum { separateSize = 16 };
    2122struct ofstream {
    2223        void * file;
    2324        _Bool sepDefault;
    2425        _Bool sepOnOff;
    25         _Bool sawNL;
     26        _Bool lastSepOn;
    2627        const char * sepCur;
    27         char separator[sepSize];
    28         char tupleSeparator[sepSize];
     28        char separator[separateSize];
     29        char tupleSeparator[separateSize];
    2930}; // ofstream
    3031
     
    3536const char * sepGetCur( ofstream * );
    3637void sepSetCur( ofstream *, const char * );
    37 _Bool getNL( ofstream * );
    38 void setNL( ofstream *, _Bool );
     38_Bool lastSepOn( ofstream * );
    3939
    4040// public
     
    7575extern ifstream * sin;
    7676
     77#endif // __FSTREAM_H__
     78
    7779// Local Variables: //
    7880// mode: c //
  • src/libcfa/fstream.c

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 18:38:25 2017
    13 // Update Count     : 251
     12// Last Modified On : Sat Jul  1 16:37:54 2017
     13// Update Count     : 242
    1414//
    1515
     
    3333        this->sepDefault = sepDefault;
    3434        this->sepOnOff = sepOnOff;
     35        this->lastSepOn = false;
    3536        sepSet( this, separator );
    3637        sepSetCur( this, sepGet( this ) );
     
    3940
    4041// private
    41 _Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
     42_Bool lastSepOn( ofstream * os ) { return os->lastSepOn; }
     43_Bool sepPrt( ofstream * os ) { os->lastSepOn = false; return os->sepOnOff; }
    4244void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    4345void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
    4446const char * sepGetCur( ofstream * os ) { return os->sepCur; }
    4547void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
    46 _Bool getNL( ofstream * os ) { return os->sawNL; }
    47 void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
    4848
    4949// public
    50 void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
    51 void sepOff( ofstream * os ) { os->sepOnOff = false; }
     50void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; }
     51void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; }
    5252
    5353_Bool sepDisable( ofstream *os ) {
    5454        _Bool temp = os->sepDefault;
    5555        os->sepDefault = false;
     56        os->lastSepOn = false;
    5657        sepReset( os );
    5758        return temp;
     
    6869void sepSet( ofstream * os, const char * s ) {
    6970        assert( s );
    70         strncpy( os->separator, s, sepSize - 1 );
    71         os->separator[sepSize - 1] = '\0';
     71        strncpy( os->separator, s, separateSize - 1 );
     72        os->separator[separateSize - 1] = '\0';
    7273} // sepSet
    7374
     
    7576void sepSetTuple( ofstream * os, const char * s ) {
    7677        assert( s );
    77         strncpy( os->tupleSeparator, s, sepSize - 1 );
    78         os->tupleSeparator[sepSize - 1] = '\0';
     78        strncpy( os->tupleSeparator, s, separateSize - 1 );
     79        os->tupleSeparator[separateSize - 1] = '\0';
    7980} // sepSet
    8081
     
    152153
    153154void open( ifstream * is, const char * name, const char * mode ) {
    154         FILE *file = fopen( name, mode );
    155         if ( file == 0 ) {                                                                      // do not change unless successful
     155        FILE *t = fopen( name, mode );
     156        if ( t == 0 ) {                                                                         // do not change unless successful
    156157                fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    157158                perror( 0 );
    158159                exit( EXIT_FAILURE );
    159160        } // if
    160         is->file = file;
     161        is->file = t;
    161162} // open
    162163
  • src/libcfa/gmp

    r29038ef re182ce3  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:33:20 2017
    13 // Update Count     : 15
     12// Last Modified On : Sat May 27 09:55:51 2017
     13// Update Count     : 14
    1414//
    1515
    1616// https://gmplib.org/gmp-man-6.1.1.pdf
    17 
    18 #pragma once
    1917
    2018#include <gmp.h>                                                                                // GNU multi-precise integers
  • src/libcfa/iostream

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:35:59 2017
    13 // Update Count     : 118
     12// Last Modified On : Sun Jul  2 08:42:56 2017
     13// Update Count     : 110
    1414//
    1515
    16 #pragma once
     16#ifndef __IOSTREAM_H__
     17#define __IOSTREAM_H__
    1718
    1819#include "iterator"
     
    2526        const char * sepGetCur( ostype * );                                     // get current separator string
    2627        void sepSetCur( ostype *, const char * );                       // set current separator string
    27         _Bool getNL( ostype * );                                                        // check newline
    28         void setNL( ostype *, _Bool );                                          // saw newline
     28        _Bool lastSepOn( ostype * );                                            // last manipulator is setOn (context sensitive)
    2929        // public
    3030        void sepOn( ostype * );                                                         // turn separator state on
     
    8282forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) );
    8383forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
    84 forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype * );
    85 forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype * );
    8684forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * );
    8785forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * );
     
    139137forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );
    140138
     139#endif // __IOSTREAM_H
     140
    141141// Local Variables: //
    142142// mode: c //
  • src/libcfa/iostream.c

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 18:14:17 2017
    13 // Update Count     : 396
     12// Last Modified On : Sun Jul  2 08:54:02 2017
     13// Update Count     : 375
    1414//
    1515
     
    1818extern "C" {
    1919#include <stdio.h>
    20 #include <stdbool.h>                                                                    // true/false
    2120#include <string.h>                                                                             // strlen
    2221#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
     
    2524
    2625forall( dtype ostype | ostream( ostype ) )
    27 ostype * ?|?( ostype * os, char ch ) {
    28         fmt( os, "%c", ch );
    29         if ( ch == '\n' ) setNL( os, true );
     26ostype * ?|?( ostype * os, char c ) {
     27        fmt( os, "%c", c );
    3028        sepOff( os );
    3129        return os;
     
    182180
    183181        // last character IS spacing or opening punctuation => turn off separator for next item
    184         size_t len = strlen( cp );
    185         ch = cp[len - 1];                                                                       // must make unsigned
     182        unsigned int len = strlen( cp ), posn = len - 1;
     183        ch = cp[posn];                                                                          // must make unsigned
    186184        if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    187185                sepOn( os );
     
    189187                sepOff( os );
    190188        } // if
    191         if ( ch == '\n' ) setNL( os, true );                            // check *AFTER* sepPrt call above as it resets NL flag
    192189        return write( os, cp, len );
    193190} // ?|?
     
    219216
    220217forall( dtype ostype | ostream( ostype ) )
    221 ostype * sep( ostype * os ) {
    222         os | sepGet( os );
    223         return os;
    224 } // sep
    225 
    226 forall( dtype ostype | ostream( ostype ) )
    227 ostype * sepTuple( ostype * os ) {
    228         os | sepGetTuple( os );
    229         return os;
    230 } // sepTuple
    231 
    232 forall( dtype ostype | ostream( ostype ) )
    233218ostype * endl( ostype * os ) {
     219        if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) );
    234220        os | '\n';
    235         setNL( os, true );
    236221        flush( os );
    237222        sepOff( os );                                                                           // prepare for next line
  • src/libcfa/iterator

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:37:25 2017
    13 // Update Count     : 10
     12// Last Modified On : Wed Mar  2 18:06:05 2016
     13// Update Count     : 9
    1414//
    1515
    16 #pragma once
     16#ifndef ITERATOR_H
     17#define ITERATOR_H
    1718
    1819// An iterator can be used to traverse a data structure.
     
    3839
    3940forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    40 void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
     41void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
    4142
    4243forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    43 void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
     44void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
     45
     46#endif // ITERATOR_H
    4447
    4548// Local Variables: //
  • src/libcfa/iterator.c

    r29038ef re182ce3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:38:23 2017
    13 // Update Count     : 28
     12// Last Modified On : Wed Mar  2 18:08:11 2016
     13// Update Count     : 27
    1414//
    1515
     
    1717
    1818forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    19 void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
     19void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
    2020        for ( iterator_type i = begin; i != end; ++i ) {
    2121                func( *i );
    22         } // for
    23 } // for_each
     22        }
     23}
    2424
    2525forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    26 void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
     26void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
    2727        for ( iterator_type i = end; i != begin; ) {
    2828                --i;
    2929                func( *i );
    30         } // for
    31 } // for_each_reverse
     30        }
     31}
    3232
    3333// Local Variables: //
  • src/libcfa/limits

    r29038ef re182ce3  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:33:57 2017
    13 // Update Count     : 7
     12// Last Modified On : Wed Apr  6 21:08:16 2016
     13// Update Count     : 6
    1414//
    1515
    16 #pragma once
     16#ifndef LIMITS_H
     17#define LIMITS_H
    1718
    1819// Integral Constants
     
    109110extern const long _Complex _1_SQRT_2;                                   // 1 / sqrt(2)
    110111
     112#endif // LIMITS_H
     113
    111114// Local Variables: //
    112115// mode: c //
  • src/libcfa/math

    r29038ef re182ce3  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:34:15 2017
    13 // Update Count     : 61
    14 //
    15 
    16 #pragma once
     12// Last Modified On : Wed May 24 17:40:39 2017
     13// Update Count     : 60
     14//
     15
     16#ifndef MATH_H
     17#define MATH_H
    1718
    1819extern "C" {
     
    344345long double scalbln( long double, long int );
    345346
     347#endif // MATH_H
     348
    346349// Local Variables: //
    347350// mode: c //
  • src/libcfa/rational

    r29038ef re182ce3  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Fri Jul  7 09:34:33 2017
    15 // Update Count     : 93
     14// Last Modified On : Mon May 15 21:30:12 2017
     15// Update Count     : 90
    1616//
    1717
    18 #pragma once
     18#ifndef RATIONAL_H
     19#define RATIONAL_H
    1920
    2021#include "iostream"
     
    4647// implementation
    4748
    48 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     49forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    4950struct Rational {
    5051        RationalImpl numerator, denominator;                            // invariant: denominator > 0
     
    5354// constructors
    5455
    55 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     56forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5657void ?{}( Rational(RationalImpl) * r );
    5758
    58 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     59forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5960void ?{}( Rational(RationalImpl) * r, RationalImpl n );
    6061
    61 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     62forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6263void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
    6364
    64 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     65forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6566void ?{}( Rational(RationalImpl) * r, zero_t );
    6667
    67 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6869void ?{}( Rational(RationalImpl) * r, one_t );
    6970
    70 // numerator/denominator getter
     71// getter for numerator/denominator
    7172
    72 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7374RationalImpl numerator( Rational(RationalImpl) r );
    7475
    75 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     76forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7677RationalImpl denominator( Rational(RationalImpl) r );
    77 
    78 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    8080
    81 // numerator/denominator setter
     81// setter for numerator/denominator
    8282
    83 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     83forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    8484RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
    8585
    86 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     86forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    8787RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    8888
    8989// comparison
    9090
    91 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     91forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9292int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9393
    94 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     94forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9595int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9696
    97 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     97forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9898int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9999
    100 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     100forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    101101int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    102102
    103 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     103forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    104104int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    105105
    106 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     106forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    107107int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    108108
    109109// arithmetic
    110110
    111 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     111forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    112112Rational(RationalImpl) +?( Rational(RationalImpl) r );
    113113
    114 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     114forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    115115Rational(RationalImpl) -?( Rational(RationalImpl) r );
    116116
    117 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     117forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    118118Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    119119
    120 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     120forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    121121Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    122122
    123 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     123forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    124124Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    125125
    126 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     126forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    127127Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    128128
    129129// conversion
    130 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
     130forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
    131131double widen( Rational(RationalImpl) r );
    132 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
     132forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
    133133Rational(RationalImpl) narrow( double f, RationalImpl md );
    134134
    135135// I/O
    136 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     136forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    137137forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    138138istype * ?|?( istype *, Rational(RationalImpl) * );
    139139
    140 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     140forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    141141forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    142142ostype * ?|?( ostype *, Rational(RationalImpl ) );
     143
     144#endif // RATIONAL_H
    143145
    144146// Local Variables: //
  • src/libcfa/rational.c

    r29038ef re182ce3  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 16 18:35:36 2017
    13 // Update Count     : 150
     12// Last Modified On : Mon May 15 21:29:23 2017
     13// Update Count     : 149
    1414//
    1515
     
    2222// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
    2323// alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
    24 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     24forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    2525static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
    2626        for ( ;; ) {                                                                            // Euclid's algorithm
     
    3333} // gcd
    3434
    35 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     35forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    3636static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
    3737        if ( *d == (RationalImpl){0} ) {
     
    4646// constructors
    4747
    48 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     48forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    4949void ?{}( Rational(RationalImpl) * r ) {
    5050        r{ (RationalImpl){0}, (RationalImpl){1} };
    5151} // rational
    5252
    53 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     53forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5454void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
    5555        r{ n, (RationalImpl){1} };
    5656} // rational
    5757
    58 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     58forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5959void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
    6060        RationalImpl t = simplify( &n, &d );                            // simplify
     
    6666// getter for numerator/denominator
    6767
    68 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6969RationalImpl numerator( Rational(RationalImpl) r ) {
    7070        return r.numerator;
    7171} // numerator
    7272
    73 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7474RationalImpl denominator( Rational(RationalImpl) r ) {
    7575        return r.denominator;
    7676} // denominator
    7777
    78 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
    8080        return *dest = src.[ numerator, denominator ];
     
    8383// setter for numerator/denominator
    8484
    85 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     85forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    8686RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
    8787        RationalImpl prev = r.numerator;
     
    9292} // numerator
    9393
    94 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     94forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9595RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
    9696        RationalImpl prev = r.denominator;
     
    104104// comparison
    105105
    106 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     106forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    107107int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    108108        return l.numerator * r.denominator == l.denominator * r.numerator;
    109109} // ?==?
    110110
    111 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     111forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    112112int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    113113        return ! ( l == r );
    114114} // ?!=?
    115115
    116 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     116forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    117117int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    118118        return l.numerator * r.denominator < l.denominator * r.numerator;
    119119} // ?<?
    120120
    121 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     121forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    122122int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    123123        return l.numerator * r.denominator <= l.denominator * r.numerator;
    124124} // ?<=?
    125125
    126 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     126forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    127127int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    128128        return ! ( l <= r );
    129129} // ?>?
    130130
    131 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     131forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    132132int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    133133        return ! ( l < r );
     
    137137// arithmetic
    138138
    139 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     139forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    140140Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
    141141        Rational(RationalImpl) t = { r.numerator, r.denominator };
     
    143143} // +?
    144144
    145 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     145forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    146146Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
    147147        Rational(RationalImpl) t = { -r.numerator, r.denominator };
     
    149149} // -?
    150150
    151 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     151forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    152152Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    153153        if ( l.denominator == r.denominator ) {                         // special case
     
    160160} // ?+?
    161161
    162 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     162forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    163163Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    164164        if ( l.denominator == r.denominator ) {                         // special case
     
    171171} // ?-?
    172172
    173 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     173forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    174174Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    175175        Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
     
    177177} // ?*?
    178178
    179 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     179forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    180180Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    181181        if ( r.numerator < (RationalImpl){0} ) {
     
    190190// conversion
    191191
    192 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
     192forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
    193193double widen( Rational(RationalImpl) r ) {
    194194        return convert( r.numerator ) / convert( r.denominator );
     
    196196
    197197// http://www.ics.uci.edu/~eppstein/numth/frap.c
    198 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
     198forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
    199199Rational(RationalImpl) narrow( double f, RationalImpl md ) {
    200200        if ( md <= (RationalImpl){1} ) {                                        // maximum fractional digits too small?
     
    227227// I/O
    228228
    229 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     229forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    230230forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    231231istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
     
    238238} // ?|?
    239239
    240 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     240forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    241241forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    242242ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
  • src/libcfa/stdlib

    r29038ef re182ce3  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:34:49 2017
    13 // Update Count     : 219
    14 //
    15 
    16 #pragma once
     12// Last Modified On : Fri Jun  2 15:51:03 2017
     13// Update Count     : 218
     14//
     15
     16#ifndef STDLIB_H
     17#define STDLIB_H
    1718
    1819//---------------------------------------
     
    231232void swap( T * t1, T * t2 );
    232233
     234#endif // STDLIB_H
     235
    233236// Local Variables: //
    234237// mode: c //
  • src/tests/.expect/io.txt

    r29038ef re182ce3  
    44123
    55
    6 opening delimiters
     6opening delimiters 
    77x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
    88
    9 closing delimiters
    10 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
     9closing delimiters 
     101, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x 
    1111
    12 opening/closing delimiters
     12opening/closing delimiters 
    1313x`1`x'2'x"3"x:4:x 5 x   6       x
    14147
     
    1919x
    202010
    21 x
     21x 
    2222
    23 override opening/closing delimiters
     23override opening/closing delimiters 
    2424x ( 1 ) x 2 , x 3 :x: 4
    2525
    26 input bacis types
     26input bacis types 
    2727
    28 output basic types
     28output basic types 
    2929A
    30301 2 3 4 5 6 7 8
     
    32321.1+2.3i 1.1-2.3i 1.1-2.3i
    3333
    34 tuples
    35 1, 2, 3 4, 5, 6
     34tuples 
     351, 2, 3 3, 4, 5
    3636
    37 toggle separator
     37toggle separator 
    38381.11.21.3
    39391.1+2.3i1.1-2.3i1.1-2.3i
    40 1.1+2.3i 1.1-2.3i1.1-2.3i
    41 1.1+2.3i 1.1-2.3i 1.1-2.3i
    42 1.1+2.3i1.1-2.3i 1.1-2.3i
    43 abcxyz
    44 abcxyz
     40 abcxyz
     41abcxyz
    4542
    46 change separator
    47 from " " to ", $"
     43change separator 
     44from "  "to " , $"
    48451.1, $1.2, $1.3
    49461.1+2.3i, $1.1-2.3i, $1.1-2.3i
    50 abc, $xyz
    51 1, 2, 3, $4, 5, 6
     47abc, $xyz, $
     481, 2, 3, $3, 4, 5
    5249
    53 from ", $" to " "
     50from ", $"to " "
    54511.1 1.2 1.3
    55521.1+2.3i 1.1-2.3i 1.1-2.3i
    56 abc xyz
    57 1, 2, 3 4, 5, 6
     53abc xyz 
     541, 2, 3 3, 4, 5
    5855
    59 check sepOn/sepOff
     56 1 2 3
     5712 3
     58 1 2 3
    60591 2 3
    61 12 3
    62 1 2 3
    63 1 2 3
     60 1 2 3
    6461
    65 1 2 3
    66 
    67 check enable/disable
    6862123
    69631 23
     
    7165123
    72661 2 3
    73 123
     67123 
    74681 2 3
    7569
    76 1 2 3 4 5 6 " "
    77 1, 2, 3 4, 5, 6 " "
    78 1, 2, 3 4, 5, 6
     701 2 3 3 4 5 " "
     711, 2, 3 3, 4, 5 ", "
     721, 2, 3 3, 4, 5
    7973
    80743, 4, a, 7.2
    81753, 4, a, 7.2
    82763 4 a 7.2
    83 3 4 a 7.234a7.23 4 a 7.2
     77 3 4 a 7.234a7.23 4 a 7.2
    84783-4-a-7.2^3^4^3-4-a-7.2
  • src/tests/io.c

    r29038ef re182ce3  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 23:26:12 2017
    13 // Update Count     : 78
     12// Last Modified On : Sun Jul  2 09:40:58 2017
     13// Update Count     : 68
    1414//
    1515
     
    104104
    105105        sout | "tuples" | endl;
    106         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     106        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    107107        sout | t1 | t2 | endl;                                                          // print tuple
    108108        sout | endl;
     
    110110        sout | "toggle separator" | endl;
    111111        sout | f | "" | d | "" | ld | endl                                      // floating point without separator
    112                 | sepDisable | fc | dc | ldc | endl                             // complex without separator
    113                 | fc | sepOn | dc | ldc | endl                                  // local separator add
    114                 | sepEnable | fc | dc | ldc | endl                              // complex with separator
    115                 | fc | sepOff | dc | ldc | endl                                 // local separator removal
    116                 | s1 | sepOff | s2 | endl                                               // local separator removal
    117                 | s1 | "" | s2 | endl;                                                  // local separator removal
     112                | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator
     113                | sepOn | s1 | sepOff | s2 | endl                               // local separator removal
     114                | s1 | "" | s2 | endl;                                                  // C string without separator
    118115        sout | endl;
    119116
    120117        sout | "change separator" | endl;
    121         sout | "from \"" | sep | "\"";
     118        sout | "from \" " | sepGet( sout ) | "\"";
    122119        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    123         sout | " to \"" | sep | "\"" | endl;
     120        sout | "to \" " | sepGet( sout ) | "\"" | endl;
    124121        sout | f | d | ld | endl
    125122                | fc | dc | ldc | endl
     
    127124                | t1 | t2 | endl;                                                               // print tuple
    128125        sout | endl;
    129         sout | "from \"" | sep | "\" ";
     126        sout | "from \"" | sepGet( sout ) | "\"";
    130127        sepSet( sout, " " );                                                            // restore separator
    131         sout | "to \"" | sep | "\"" | endl;
     128        sout | "to \"" | sepGet( sout ) | "\"" | endl;
    132129        sout | f | d | ld | endl
    133130                | fc | dc | ldc | endl
     
    136133        sout | endl;
    137134
    138         sout | "check sepOn/sepOff" | endl;
    139         sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // no separator at start/end of line
     135        sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // separator at start/end of line
    140136        sout | 1 | sepOff | 2 | 3 | endl;                                       // locally turn off implicit separator
    141         sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line
    142         sout | 1 | 2 | 3 | "\n\n" | sepOn;                                      // no separator at start of next line
     137        sout | sepOn | 1 | 2 | 3 | sepOn | sepOff | endl;       // separator at start of line
     138        sout | 1 | 2 | 3 | endl | sepOn;                                        // separator at start of next line
    143139        sout | 1 | 2 | 3 | endl;
    144140        sout | endl;
    145141
    146         sout | "check enable/disable" | endl;
    147142        sout | sepDisable | 1 | 2 | 3 | endl;                           // globally turn off implicit separation
    148143        sout | 1 | sepOn | 2 | 3 | endl;                                        // locally turn on implicit separator
     
    154149        sout | endl;
    155150
    156 //      sout | fmt( d, "%8.3f" ) || endl;
    157 //      sout | endl;
    158 
    159151        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
    160         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     152        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    161153        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
    162         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     154        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    163155        sout | t1 | t2 | endl;                                                          // print tuple
    164156        sout | endl;
Note: See TracChangeset for help on using the changeset viewer.