Changes in / [7cd8827:5a5d31a]
- Location:
- examples
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/Tuple.c
r7cd8827 r5a5d31a 1 1 int f( int, int ); 2 2 int g( int, int, int ); 3 static 4 [ int, int *, * int, int ] h( int a, int b, * int c, [] char d ); 3 static [ int, int *, * int, int ] h( int a, int b, * int c, [] char d ); 5 4 6 5 struct inner { … … 15 14 16 15 const volatile [ int, int ] t1; 17 static const [ int, int ] t2;16 static const [ int, const int ] t2; 18 17 const static [ int, const int ] t3; 19 18 … … 22 21 23 22 [ short x, unsigned y ] f1( int w ) { 24 // return[ y, x ] = [ x, y ] = [ w, 23 ];23 [ y, x ] = [ x, y ] = [ w, 23 ]; 25 24 } 26 25 27 26 [ [ int, char, long, int ] r ] g1() { 28 short intx, p;27 short x, p; 29 28 unsigned int y; 30 29 [ int, int ] z; 31 30 32 [ x, y, z ] = [ p, f( 17 , 18 ), 4, 3 ];33 // [ x, y, z ] = ([short, unsigned int, [int, int]])([ p, f( 17, 18 ), 4, 3 ]);31 [ x, y, z ] = [ p, f( 17 ), 3 ]; 32 [ x, y, z ] = ([short, unsigned int, [int, int]])([ p, f( 17 ), 3 ]); 34 33 r = [ x, y, z ]; 35 34 } … … 37 36 [ int rc ] main( int argc, ** char argv ) { 38 37 int a, b, c, d; 39 // struct outer t = { .[ f1, f4 ] : [ 1,7.0 ] };38 struct outer t = { .[ f1,f4 ] : [ 1,7.0 ] }; 40 39 f( [ 3,5 ] ); 41 40 g( [ 3,5 ], 3 ); … … 43 42 g( t1, 3 ); 44 43 45 //[ , , , ]; /* empty tuple */44 [ , , , ]; /* empty tuple */ 46 45 [ 3, 5 ]; 47 46 [ a, b ] = 3; 48 // [ a, b ] = [ 4.6 ]; 49 [ a, b ] = 4.6; 47 [ a, b ] = [ 4.6 ]; 50 48 [ a, b ] = [ c, d ] = [ 3, 5 ]; 51 // [ a, b, [ c ] ] = [ 2, [ a, b ] ]; 52 [ a, b, c ] = [ 2, [ a, b ] ]; 49 [ a, b, [ c ] ] = [ 2,[ a, b ] ]; 53 50 [ a, b ] = 3 > 4 ? [ b, 6 ] : [ 7, 8 ]; 54 51 … … 59 56 [ a, b ] = t1 = [ c, d ]; 60 57 [ a, b ] = t1 = t2 = [ c, d ]; 61 //t1 = [ 3, 4 ] = [ 3, 4 ] = t1 = [ 3, 4 ];58 t1 = [ 3, 4 ] = [ 3, 4 ] = t1 = [ 3, 4 ]; 62 59 63 60 s.[ f1, i.[ f2, f3 ], f4 ] = [ 11, 12, 13, 3.14159 ]; 64 // s.[ f1, i.[ f2, f3 ], f4 ] = h( 3, 3, (* int)0, "abc" );65 //[ a, , b, ] = h( 3, 3, 0, "abc" ); /* ignore some results */66 sp->[ f4, f1 ] = sp->[ f1, f4 ];61 s.[ f1, i.[ f2, f3 ], f4 ] = h( 3, 3, 0, "abc" ); 62 [ a, , b, ] = h( 3, 3, 0, "abc" ); /* ignore some results */ 63 sp->[ f4,f1 ] = sp->[ f1, f4 ]; 67 64 printf( "expecting 3, 17, 23, 4; got %d, %d, %d, %d\n", s.[ f4, i.[ f3, f2 ], f1 ] ); 68 65 rc = 0; -
examples/includes.c
r7cd8827 r5a5d31a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Nov 15 23:06:24 201713 // Update Count : 59712 // Last Modified On : Tue Jul 12 17:59:25 2016 13 // Update Count : 371 14 14 // 15 15 … … 22 22 #endif // __CFA__ 23 23 24 #if 0 24 25 #if 1 25 26 #define _GNU_SOURCE 27 #include <aio.h> 26 28 #include <a.out.h> 27 #include <aio.h>28 29 #include <aliases.h> 29 30 #include <alloca.h> … … 33 34 #include <argz.h> 34 35 #include <assert.h> 35 //#include <bfd.h>36 // #include <bfdlink.h> // keyword with 36 #include <bfd.h> 37 #include <bfdlink.h> 37 38 #include <byteswap.h> 38 #include <bzlib.h>39 39 #include <cblas.h> 40 40 #include <cblas_f77.h> 41 41 #include <complex.h> 42 #include <com_err.h>43 42 #include <cpio.h> 44 43 #include <crypt.h> 45 44 #include <ctype.h> 46 45 #include <curses.h> 46 //#include <demangle.h> 47 47 #include <dialog.h> 48 48 #include <dirent.h> 49 49 #include <dis-asm.h> 50 #endif 51 #if 0 50 52 #include <dlfcn.h> 51 53 #include <dlg_colors.h> … … 61 63 #include <evdns.h> 62 64 #include <event.h> 63 64 // #include <evhttp.h> 65 // #include <sys/queue.h> 66 // #include <evrpc.h> // evrpc.h depends on sys/queue.h 67 // #include <evutil.h> 68 // #include <execinfo.h> 69 // #include <expat.h> 70 // #include <expat_config.h> 71 // #include <expat_external.h> 72 // #include <fcntl.h> 73 // #include <features.h> 74 // #include <fenv.h> 75 // #include <fmtmsg.h> 76 // #include <fnmatch.h> 77 // #include <form.h> 78 // #include <fpu_control.h> 79 // #include <fstab.h> 80 // #include <fts.h> 81 // #include <ftw.h> 82 // #include <gconv.h> 83 // #include <getopt.h> 84 // #include <gettext-po.h> 85 // #include <glob.h> 86 // #include <gmp.h> 87 // #include <gnu-versions.h> 88 // #include <grp.h> 89 // #include <gshadow.h> 90 // #include <gssapi.h> 91 // #include <hwloc.h> // keyword thread (setjmp) 92 // #include <iconv.h> 93 // #include <idna.h> 94 // #include <idn-free.h> 95 // #include <idn-int.h> 96 // #include <idn-int.h> 97 // #include <ifaddrs.h> 98 // #include <inttypes.h> 99 // #include <jerror.h> 100 65 #include <evhttp.h> 66 #endif 67 #if 0 68 #include <evrpc.h> 69 #include <evutil.h> 70 #include <execinfo.h> 71 #include <expat.h> 72 #include <expat_config.h> 73 #include <expat_external.h> 74 #include <fcntl.h> 75 #include <features.h> 76 #include <fenv.h> 77 #include <float.h> 78 #include <fmtmsg.h> 79 #include <fnmatch.h> 80 #include <form.h> 81 #include <fpu_control.h> 82 #include <fstab.h> 83 //#include <ft2build.h> 84 #include <fts.h> 85 #include <ftw.h> 86 #include <gconv.h> 87 //#include <gcrypt.h> 88 //#include <gcrypt-module.h> 89 #include <getopt.h> 90 //#include <gettext-po.h> 91 #include <glob.h> 92 //#include <gmp.h> // infinite loop 93 ////#include <gmpxx.h> 94 //#include <gmp-x86_64.h> 95 #include <gnu-versions.h> 96 //#include <gpg-error.h> 97 #include <grp.h> 98 #include <gshadow.h> 99 #include <iconv.h> 100 #include <idna.h> 101 #include <idn-free.h> 102 #include <idn-int.h> 103 #include <ieee754.h> 104 #include <ifaddrs.h> 105 #include <inttypes.h> 106 #include <iso646.h> 107 #include <jerror.h> 101 108 //#include <jmorecfg.h> 102 109 //#include <jpegint.h> 103 // #include <jpeglib.h> 104 // #include <kdb.h> 105 // #include <krb5.h> // keyword enable 106 // #include <langinfo.h> 107 // #include <lastlog.h> 108 // #include <lber.h> 109 // #include <lber_types.h> 110 // #include <ldap.h> 111 // #include <ldap_cdefs.h> 112 // #include <ldap_features.h> 113 // #include <ldap_schema.h> 114 // #include <ldap_utf8.h> 115 // #include <ldif.h> 116 // #include <libgen.h> 117 // #include <libintl.h> 118 // #include <libio.h> 119 // #include <libtasn1.h> 120 // #include <libudev.h> 121 // #include <limits.h> 122 // #include <link.h> 123 // #include <locale.h> 124 // #include <ltdl.h> 125 // #include <lzma.h> 126 // #include <malloc.h> 127 // #include <math.h> 128 // #include <mcheck.h> 129 // #include <memory.h> 130 // #include <menu.h> 131 // #include <mntent.h> 132 // #include <monetary.h> 133 // #include <mqueue.h> 134 // #include <ncurses.h> 135 // #include <ncurses_dll.h> 136 // #include <nc_tparm.h> 137 // #include <netdb.h> 138 // #include <nl_types.h> 139 // #include <nss.h> 140 // #include <numa.h> 141 // #include <numacompat1.h> 142 // #include <numaif.h> 143 // #include <obstack.h> 144 // #include <panel.h> 145 // #include <paths.h> 146 // #include <pciaccess.h> 147 // #include <pcre.h> 148 // //#include <pcreposix.h> // conflicts with regex.h 149 // #include <plugin-api.h> 150 // #include <png.h> // setjmp 151 // #include <pngconf.h> // setjmp 152 // #include <poll.h> 153 // #include <pr29.h> 154 // #include <printf.h> 155 // #include <profile.h> 156 // #include <pthread.h> // setjmp 157 // #include <pty.h> 158 // #include <punycode.h> 159 // #include <pwd.h> 160 // #define INIT ; // needed for regex.h 161 // #define GETC() 'a' 162 // #define PEEKC() 'a' 163 // #define UNGETC( c ) ; 164 // #define RETURN( ptr ) ; 165 // #define ERROR( val ) ; 166 // #include <regex.h> 167 // //#include <regexp.h> // GNU C Library no longer implements 168 // #include <resolv.h> 169 // #include <re_comp.h> 170 // #include <sched.h> 171 // #include <search.h> 172 // #include <semaphore.h> 173 // #include <setjmp.h> 174 // #include <sgtty.h> 175 // #include <shadow.h> 176 // #include <signal.h> 177 // #include <spawn.h> 178 // #include <stab.h> 179 // #include <stdatomic.h> 180 // #include <stdarg.h> 181 // #include <stdbool.h> 182 // #include <stdint.h> 183 // #include <stddef.h> 184 // #include <stdio.h> 185 // #include <stdio_ext.h> 186 // #include <stdlib.h> 187 // #include <string.h> 188 // #include <stringprep.h> 189 // #include <strings.h> 190 // #include <stropts.h> 191 // #include <sudo_plugin.h> 192 // #include <symcat.h> 193 // #include <syscall.h> 194 // #include <sysexits.h> 195 // #include <syslog.h> 196 // #include <tar.h> 197 // #include <term.h> 198 // #include <termcap.h> 199 // #include <termio.h> 200 // #include <termios.h> 201 // //#include <term_entry.h> 202 // #include <tgmath.h> 203 // #include <thread_db.h> // CFA bug 204 // #include <tic.h> 205 // #include <time.h> 206 // #include <tld.h> 207 // #include <ttyent.h> 208 // #include <turbojpeg.h> 209 // #include <ucontext.h> 210 // #include <ulimit.h> 211 // #include <unctrl.h> 212 // #include <unistd.h> 213 // #include <ustat.h> 214 // #include <utime.h> 215 // #include <utmp.h> 216 // #include <utmpx.h> 217 // #include <wait.h> 218 // #include <wchar.h> 219 // #include <wctype.h> 220 // #include <wordexp.h> 221 // #include <xlocale.h> 222 // #include <values.h> 223 // #include <zconf.h> 224 // #include <zlib.h> 225 // #include <_G_config.h> 226 227 // #include <jpeglib.h> // after stdlib.h/stdio.h 228 // #include <jpegint.h> 229 // #include <jmorecfg.h> 230 #if 0 110 //#include <jpeglib.h> 111 #include <limits.h> 112 #include <locale.h> 113 #include <math.h> 114 #include <ncurses.h> 115 #include <setjmp.h> 116 #include <signal.h> 117 #include <stdarg.h> 118 #include <stdbool.h> 119 #include <stddef.h> 120 #include <stdlib.h> 121 #include <stdio.h> 122 #include <string.h> 123 #include <tgmath.h> 124 #include <time.h> 125 #include <unistd.h> 126 #include <wchar.h> 127 #include <wctype.h> 231 128 #endif // 0 232 129 … … 234 131 235 132 #define _GNU_SOURCE 133 //#include <bfd.h> 134 //#include <error.h> 236 135 237 #include < setjmp.h>136 #include <demangle.h> 238 137 239 138 #endif // 0 -
examples/twice.c
r7cd8827 r5a5d31a 7 7 // twice.c -- 8 8 // 9 // Author : Peter A. Buhr9 // Author : Richard C. Bilson 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Oct 19 21:52:57 201713 // Update Count : 4612 // Last Modified On : Tue Mar 8 22:04:58 2016 13 // Update Count : 16 14 14 // 15 15 16 16 #include <fstream.hfa> 17 17 18 forall( otype T | { T ?+?( T, T ); } )18 forall( otype T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } ) 19 19 T twice( const T t ) { 20 20 return t + t; 21 21 } 22 22 23 // char does not have addition 24 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 23 int main( void ) { 24 // char does not have addition 25 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 26 char ++?( char *op ) { *op += 1; return *op; } 27 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 25 28 26 // signed char does not have addition 27 signed char ?+?( signed char op1, signed char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 28 29 int main( void ) { 30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ) | endl; 29 sout | twice( 'a' ) | ' ' | twice( 1 ) | twice( 3.2 ) | endl; 31 30 } 32 31
Note:
See TracChangeset
for help on using the changeset viewer.