-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathching
executable file
·2891 lines (2761 loc) · 74.9 KB
/
ching
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
=begin metadata
Name: ching
Description: the Book of Changes
Author: Albert Dvornik, [email protected]
License: bsd
=end metadata
=cut
#
# Perl code is Copyright (c) 1995, 1999 Albert Dvornik <[email protected]>
#
# Hexagram text is Copyright (c) 1988 The Regents of the University of
# California. [Please see below for more information!]
use strict;
=head1 NAME
ching - the Book of Changes
=head1 SYNOPSIS
B<ching> [B<-n>] [B<-r>] [B<-h>] [B<-p> I<program>] [I<hexagram-lines>]
=cut
## usage
sub usage { die "usage: ching [-nrh] [-p pager] [hexagram-number]\n"; }
=head1 DESCRIPTION
The I<I Ching> or I<Book of Changes> is an ancient Chinese oracle that
has been in use for centuries as a source of wisdom and advice.
The text of the I<oracle> (as it is sometimes known) consists of
sixty-four I<hexagrams>, each symbolized by a particular arrangement
of six straight (---) and broken (S<- ->) lines.
Each hexagram consists of two major sections. The B<Judgement>
relates specifically to the matter at hand (For instance, "It furthers
one to have somewhere to go.") while the B<Image> describes the
general attributes of the hexagram and how they apply to one's own
life ("Thus the superior man makes himself strong and untiring.").
=head2 The Lines
The lines are associated with numeric values ranging from six through
nine. The even values (6 and 8) indicate broken lines, while the odd
values (7 and 9) indicate solid lines.
When the value is six or nine, the line is said to be I<moving>; for
any such line there is an appended judgement which becomes
significant. Furthermore, the moving lines are inherently unstable
and change into their opposites; a second hexagram (and thus an
additional judgement) is formed.
The numeric value of a hexagram is constructed by listing the digits
corresponding to each of the lines, going from the bottom upward.
=cut
## These are the traditional numeric values for the lines:
# 6 --- "old yin": broken (yin) moving to solid (yang)
# 7 --- "young yang": solid (yang)
# 8 --- "young yin": broken (yin)
# 9 --- "old yang": solid (yang) moving to broken (yin)
use vars qw( @hex_lines %hexagram );
## Traditional ordering of the hexagrams
@hex_lines = qw( 777777 888888 788878 878887 777878 878777 878888 888878
777877 778777 777888 888777 787777 777787 887888 888788
788778 877887 778888 888877 788787 787887 888887 788888
788777 777887 788887 877778 878878 787787 887778 877788
887777 777788 888787 787888 787877 778787 887878 878788
778887 788877 777778 877777 888778 877888 878778 877878
787778 877787 788788 887887 887877 778788 787788 887787
877877 778778 878877 778878 778877 887788 787878 878787 );
## Get hexagram number given its lines
%hexagram = map( ($hex_lines[$_], $_+1), 0..$#hex_lines );
## hexagram generation code
=head2 Consulting the Oracle
Normally, one consults the oracle by fixing the desired question
firmly in mind and then casting a set of changes (lines) using
yarrow-stalks or tossed coins. The resulting hexagram will be the
answer to the question.
This oracle simply reads a question from the standard input (up to an
C<EOF>, or a period on a line by itself) and hashes the individual
characters in combination with the time of day, process ID and the
user's user and group IDs. The resulting value is used as the seed of
a random number generator which drives a simulated coin-toss
divination. The answer is then formatted and written to the standard
output.
=cut
# Read the question and hash it by adding all the characters together.
# Then get a set of six lines making up a change (pair of hexagrams).
sub ask_and_toss {
my $question = 0;
print STDERR "Type your question now. ",
"End with control-D or a dot on a line by itself.\n"
if -t STDIN;
LINE:
while (<STDIN>) {
last LINE if /^\.$/;
$question += unpack('%8C*', $_);
}
srand(time + (31 * $question) + $< + $( + $$);
# There are two traditional methods of generating line values.
# What we do here, for each line, is to toss 3 (imaginary) coins,
# count the number of heads and add 6. If we were really hardcore,
# we'd instead simulate the mechanical interactions of a bunch of
# (imaginary) yarrow stalks, which is considered a superior method
# of consulting the Oracle. Patches are welcome. =)
(6 + unpack "%8b*", chr rand 8)
. (6 + unpack "%8b*", chr rand 8)
. (6 + unpack "%8b*", chr rand 8)
. (6 + unpack "%8b*", chr rand 8)
. (6 + unpack "%8b*", chr rand 8)
. (6 + unpack "%8b*", chr rand 8);
}
# Get the first and second hexagram of a pair, given the lines.
sub first_hex {
my ($chg) = @_;
$chg =~ s/6/8/g; $chg =~ s/9/7/g;
$hexagram{$chg};
}
sub second_hex {
my ($chg) = @_;
$chg =~ s/6/7/g; $chg =~ s/9/8/g;
$hexagram{$chg};
}
## extract data and generate output
# Take the set of lines and display the hexagrams.
sub hexagram {
my ($change) = @_; # string of lines
my $hex1 = first_hex($change);
my $hex2 = second_hex($change);
my ($macros, $text1, $text2);
# Read the macro definitions.
$macros = get_macros();
# Search for the first hexagram.
$_ = <DATA> while defined($_) && !/^\.H\s+($hex1|$hex2)\s/;
defined $_ || die "ching: Hexagram $hex1 or $hex2 missing!\n";
if ($1 eq $hex1) {
$text1 = get_hex_body($change, $1);
} else {
$text2 = get_hex_body('', $1);
}
return ($macros, $text1) if $hex1 == $hex2;
# Search for the second hexagram.
$_ = <DATA> while defined($_) && !/^\.H\s+($hex1|$hex2)\s/;
defined $_ || die "ching: Hexagram $hex1 or $hex2 missing!\n";
if ($1 eq $hex1) {
$text1 = get_hex_body($change, $1);
} else {
$text2 = get_hex_body('', $1);
}
defined $text1 && defined $text2
or die "ching: Hexagram text was repeated!\n";
($macros, $text1, $text2);
}
## hexagram text parsing
use vars qw( $show_lines );
## hexagram file format:
# .H <number> "<Chinese name>" "<English name>"
# .X <trigram> <trigram>
# .J
# <judgement for the hexagram>
# .I
# <image for the hexagram>
# for each of the six lines:
# .L <line-number> <6 or 9> [optional C or G]
# <change description>
# optional, only for hexagrams 1 (999999) and 2 (666666):
# .LA <6 or 9>
# <comment if all lines are 6 or 9>
sub get_hex_body {
my ($change, $hex) = @_;
my (@chunk, $body);
$show_lines = 1;
# Record the hexagram description, trigrams, judgement and image.
defined($_) && (@chunk = /^\.H (\d+) "(.*?)" "(.*?)"/) && ($chunk[0] == $hex)
or die "ching: Hexagram header (.H) is corrupt for hexagram $hex\n";
$body = handle_hex(@chunk);
defined($_ = <DATA>) && (@chunk = /^\.X (\d+) (\d+)/)
or die "ching: Trigrams (.X) are missing for hexagram $hex\n";
$body .= handle_trigrams(@chunk);
defined($_ = <DATA>) && /^\.J$/
or die "ching: Judgement (.J) is missing for hexagram $hex\n";
@chunk = ($_);
push @chunk, $_ while defined($_ = <DATA>) && !/^\./;
$body .= join '', handle_judgement(@chunk);
defined($_) && /^\.I$/
or die "ching: Image (.I) is missing for hexagram $hex\n";
@chunk = ($_);
push @chunk, $_ while defined($_ = <DATA>) && !/^\./;
$body .= join '', handle_image(@chunk);
# Print commentary for each moving line.
for my $line (split //, $change) {
defined($_) && /^\.L /
or die "ching: Some changes (.L) are missing for hexagram $hex\n";
@chunk = ($_);
push @chunk, $_ while defined($_ = <DATA>) && !/^\./;
$body .= join '', handle_change(@chunk)
if ($line eq '6') || ($line eq '9');
}
# Print appropriate commentary if all lines are changing together.
if (($change eq '6'x6) || ($change eq '9'x6)) {
defined($_) && /^\.LA /
or die "ching: All-lines change (.LA) is missing for hexagram $hex\n";
@chunk = ($_);
push @chunk, $_ while defined($_ = <DATA>) && !/^\./;
$body .= join '', handle_change(@chunk);
}
$body;
}
## parsing command line args
=head1 OPTIONS
The B<-n> option will cause *ROFF commands to be piped through nroff(1)
for output formatting, as they were in original BSD implementation. By
default, the formatting is done by the C<ching> program itself.
The B<-r> option will cause *ROFF formatting commands to be sent to the
standard output. You probably won't find this very useful unless you're
debugging the B<-n> switch.
The B<-p> option specifies the command to use to display the output.
The default is the value of the environment variable CHING_PAGER, or
of PAGER, or none if neither environment variable is set.
For those who wish to remain steadfast in the old traditions, the
oracle will also accept the results of a personal divination using
yarrow sticks or coins. To do this, cast the change and then type the
resulting line values as an argument.
Conversely, the B<-h> option can be used to display the line values
from a divination cast by the computer.
=cut
use vars qw( $spew_roff $spew_number );
my ($pager, $format);
while (@ARGV && ($ARGV[0] =~ /^-/)) {
foreach (split //, shift(@ARGV)) {
next if $_ eq '-';
($_ eq 'n') && ($spew_roff = 1, $format = '| nroff -', next);
($_ eq 'r') && ($spew_roff = 1, next);
($_ eq 'h') && ($spew_number = 1, next);
($_ eq 'p') && (@ARGV || usage, $pager = shift(@ARGV), next);
usage;
}
}
@ARGV > 1 and usage;
my $change = @ARGV ? shift @ARGV : ask_and_toss();
$change =~ /^[6789]{6}$/ or usage;
$pager = $ENV{'CHING_PAGER'} unless defined $pager;
$pager = $ENV{'PAGER'} unless defined $pager;
## generating output
exit !print "$change\n" if $spew_number;
my @output = hexagram($change);
$format = '' unless defined $format;
$format .= "| $pager" if defined $pager && length $pager;
open(SPEW, '<', $format) ? select(SPEW) : warn "Can't open pipe to `$format'"
if length($format);
print @output;
select(STDOUT);
close(SPEW) if defined fileno SPEW;
## macro extraction
sub get_macros {
if ($spew_roff) {
# if outputting roff, just read the macros and return the value
my $macros;
{
local ($/) = "\n__";
$macros = <DATA>;
substr($macros, -2, 2, '') eq '__'
or die "ching: Hexagram text delimiter is missing!\n";
}
defined ($_ = <DATA>)
or die "ching: Hexagram text delimiter ends the file!\n";
$macros;
} else {
# if formatting ourselves, extract various chunks of text
handle_macro() while defined($_ = <DATA>) && !/^__/;
defined $_ or die "ching: Hexagram text is missing!\n";
"\n";
}
}
## output generation hooks
my %text;
# Handle a line of macro defs
sub handle_macro {
/^\.ds\s+N(\d)\s+(.*?)$/
&& ($text{"num$1"} = $2, return);
/^\.ds\s+L(\d)\s+(.*?)$/
&& ($text{"place$1"} = $2, return);
/^\.ds\s+T(\d)\s+(.*?)$/
&& ($text{"trigram$1"} = $2, return);
/^\.XX\s.*?"(.*?)"/
&& ($text{exists $text{'above'} ? 'below' : 'above'} = $1, return);
/^\.ds\s+LH\s+(.*?)$/
&& ($text{'lines'} = $1, return);
/^([^\.\\\t].*?)$/
&& ($text{exists $text{'judgement'} ? 'image' : 'judgement'} = $1, return);
/^\\\\\*\(GR\s+\\\\\$1\s+\\\\\$2\s+(.*?)\\/
&& ($text{'means'} = $1, return);
/'(\d)'\s+\.LX\s+"(.*?)"\s+"(.*?)"/
&& ($text{"all$1"} = "$2 $3", return);
}
# Generate underlining via backspaces.
sub under { my ($text) = @_; $text =~ s/(.)/_\b$1/g; $text; }
# Convert a string into what nroff would print out for it. (Simplistic.)
sub nroff ($) {
local ($_) = @_;
die "ching: oops! internal error" unless defined $_;
s/\\([ '])/$1/g; # turn \' into ' etc.
s/\\fI(.*?)\\fR/under($1)/ge; # map \fI and \fR into underlining
s/\\f\w//g; # skip \fX if not matching
s/\\\(em/-/g; # turn \(em into - [follow nroff, don't use --]
s/\\o'(.)(.)'/$1\b$2/g; # make \o'^e' (overstrike) insert a backspace
$_;
}
# Generate a trigram with appropriate text.
sub trigram {
my ($tri, $where) = @_;
my $desc = nroff $text{"trigram$tri"};
$tri--;
my @lines = map( ($tri & $_) ? '-- --' : '-----', 4, 2, 1 );
<<"EndOfTrigram";
$lines[0]
$lines[1] $where $desc
$lines[2]
EndOfTrigram
}
# Handle a starting line of a hexagram (return appropriate text)
sub handle_hex {
return $_ if $spew_roff; # if outputting roff, just return the line
my ($num, $chinese, $local) = @_;
sprintf "\n %-5.5s%s / %s\n\n", "$num.", nroff $chinese, nroff $local;
}
# Handle a pair of trigrams making up a hexagram (return appropriate text)
sub handle_trigrams {
return $_ if $spew_roff; # if outputting roff, just return the line
my ($top, $bot) = @_;
trigram($top, nroff $text{'above'})
. trigram($bot, nroff $text{'below'});
}
# Handle the judgement block for a hexagram (return appropriate text)
sub handle_judgement {
return @_ if $spew_roff; # if outputting roff, just return the lines
shift;
"\n ", nroff($text{'judgement'}), "\n\n", map ' 'x10 . nroff($_), @_;
}
# Handle the image block for a hexagram (return appropriate text)
sub handle_image {
return @_ if $spew_roff; # if outputting roff, just return the lines
shift;
"\n ", nroff($text{'image'}), "\n\n", map(' 'x10 . nroff($_), @_), "\n";
}
# Handle the change block for a line (return appropriate text)
sub handle_change {
return @_ if $spew_roff; # if outputting roff, just return the lines
my @lines;
push @lines, " $text{'lines'}\n\n" if $show_lines;
$show_lines = 0;
my ($all, $where, $val, $cg)
= ($_[0] =~ /^\.L(?:(A)|\s+(\d))\s+(\d)\s*([CG]?)/)
or die "ching: Malformed change line: $_[0]";
shift;
my $mark = ($cg eq 'C' ? '[]' : ($cg eq 'G' ? '()' : ''));
my $info = nroff $text{$all ? "all$val" : "num$val"};
$info .= ' ' . nroff $text{"place$where"} if defined $where;
$info .= ' ' . nroff $text{'means'};
push @lines, sprintf " %-5.5s%s\n", $mark, $info;
@lines, map(' 'x10 . nroff($_), @_), "\n";
}
## final bits of documentation
=head1 COPYRIGHT
The Perl code is copyright (c) 1995, 1999 Albert Dvornik <[email protected]>.
The hexagram text and ROFF macros are Copyright (c) 1988 The Regents
of the University of California. All rights reserved. This product
includes software developed by the University of California, Berkeley
and its contributors.
=head2 About The Hexagram Text Copyright
In the original BSD version, the macros and the hexagram text resided
in separate files from the program source, and neither of these files
contained a copyright notice. I'm working under the assumption that
they were intended to be covered by the same copyright as the program
source, which is the copyright displayed above. If you have reason to
believe otherwise, please let me know.
Also, please drop me a line if you know of a freely available I<I Ching>
text that's not encumbered by the Obnoxious BSD Advertising Clause.
=head1 SEE ALSO
It furthers one to see the great man.
=head1 DIAGNOSTICS
Thus the superior man at nightfall
Goes indoors for rest and recuperation.
=head1 BUGS
The program does not support simulated tossing of yarrow stalks as a
way of consulting the oracle.
=cut
### NB: This copyright applies *ONLY* to the macros and text, appended below.
#
# Hexagram text and *ROFF macros Copyright (c) 1988 The Regents of the
# University of California. All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that: (1) source distributions retain this entire copyright
# notice and comment, and (2) distributions including binaries display
# the following acknowledgement: ``This product includes software
# developed by the University of California, Berkeley and its
# contributors'' in the documentation or other materials provided with
# the distribution and in all advertising materials mentioning features
# or use of this software. Neither the name of the University nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
__DATA__
.ds N6 Six
.ds N9 Nine
.ds L1 at the beginning
.ds L2 in the second place
.ds L3 in the third place
.ds L4 in the fourth place
.ds L5 in the fifth place
.ds L6 at the top
.ds GR ()
.ds CR []
.ds BL \(em\(em\ \(em\(em
.ds SL \(em\(em\(em\(em\(em
.ds T1 Ch\'ien\ The Creative, Heaven
.ds T2 Sun\ \ \ \ The Gentle, Wind
.ds T3 Li\ \ \ \ \ The Clinging, Flame
.ds T4 K\o'^e'n\ \ \ \ Keeping Still, Mountain
.ds T5 Tui\ \ \ \ The Joyous, Lake
.ds T6 K\'an\ \ \ The Abysmal, Water
.ds T7 Ch\o'^e'n\ \ \ The Arousing, Thunder
.ds T8 K\'un\ \ \ The Receptive, Earth
.de H
.ds LH The Lines
.in 0
.ta 0.5i 1.0i 1.5i 2.0i
.na
.nf
.sp 2
\\$1. \\$2 / \\$3
..
.de X
.sp
.XX \\$1 "above" "\\*(T\\$1"
.XX \\$2 "below" "\\*(T\\$2"
..
.de XX
.ie \\$1>4 \\*(BL
.el \\*(SL
.ie (\\$1-1%4)>1 \\*(BL\\c
.el \\*(SL\\c
\\$2 \\$3
.ie \\$1%2 \\*(SL
.el \\*(BL
..
.de J
.in 0
.sp
The Judgement
.na
.nf
.in 0.5i
.sp
..
.de I
.in 0
.sp
The Image
.na
.nf
.sp
.in 0.5i
..
.de LX
.in 0.5i
.ti -0.5i
.if '\\$3'G' \\{\\
\\*(GR \\$1 \\$2 means:\\}
.if '\\$3'C' \\{\\
\\*(CR \\$1 \\$2 means:\\}
.if '\\$3'' \\{\\
\\$1 \\$2 means:\\}
..
.de L
.if !'\\*(LH'' \\{\\
.in 0
.sp
\\*(LH
.rm LH
.in 0.5i\\}
.sp
.LX "\\*(N\\$2" "\\*(L\\$1" \\$3
.na
.nf
..
.de LA
.sp
.if '\\$1'6' .LX "When all the lines are" "sixes, it"
.if '\\$1'9' .LX "When all the lines are" "nines, it"
.na
.nf
..
.po 0.5i
__HEXAGRAM_TEXT__
.H 1 "Ch\'ien" "The Creative"
.X 1 1
.J
The Creative works sublime success,
Furthering through perseverance.
.I
The movement of heaven is full of power.
Thus the superior man makes himself strong and untiring.
.L 1 9
Hidden dragon. Do not act.
.L 2 9
Dragon appearing in the field.
It furthers one to see the great man.
.L 3 9
All day long the superior man is creatively active.
At nightfall his mind is still beset with cares.
Danger. No blame.
.L 4 9
Wavering flight over the depths.
No blame.
.L 5 9 G
Flying dragon in the heavens.
It furthers one to see the great man.
.L 6 9
Arrogant dragon will have cause to repent.
.LA 9
There appears a flight of dragons without heads.
Good fortune.
.H 2 "K\'un" "The Receptive"
.X 8 8
.J
The Receptive brings about sublime success,
Furthering through the perseverance of a mare.
If the superior man undertakes something and tries to lead,
He goes astray;
But if he follows, he finds guidance.
It is favorable to find friends in the west and south,
To forego friends in the east and north.
Quiet perseverance brings good fortune.
.I
The earth's condition is receptive devotion.
Thus the superior man who has breadth of character
Carries the outer world.
.L 1 6
When there is hoarfrost underfoot,
Solid ice is not far off.
.L 2 6 G
Straight, square, great.
Without purpose,
Yet nothing remains unfurthered.
.L 3 6
Hidden lines.
One is able to remain persevering.
If by chance you are in the service of a king,
Seek not works, but bring to completion.
.L 4 6
A tied-up sack. No blame, no praise.
.L 5 6
A yellow lower garment brings supreme good fortune.
.L 6 6
Dragons fight in the meadow.
Their blood is black and yellow.
.LA 6
Lasting perseverance furthers.
.H 3 "Chun" "Difficulty at the Beginning"
.X 6 7
.J
Difficulty at the Beginning works supreme success,
Furthering through perseverance.
Nothing should be undertaken.
It furthers one to appoint helpers.
.I
Clouds and thunder:
The image of Difficulty at the Beginning.
Thus the superior man
Brings order out of confusion.
.L 1 9 G
Hesitation and hindrance.
It furthers one to remain persevering.
It furthers one to appoint helpers.
.L 2 6
Difficulties pile up.
Horse and wagon part.
He is not a robber;
He wants to woo when the time comes.
The maiden is chaste,
She does not pledge herself.
Ten years\(emthen she pledges herself.
.L 3 6
Whoever hunts deer without the forester
Only loses his way in the forest.
The superior man understands the signs of the time
And prefers to desist.
To go on brings humiliation.
.L 4 6
Horse and wagon part.
Strive for union.
To go brings good fortune.
Everything acts to further.
.L 5 9 G
Difficulties in blessing.
A little perseverance brings good fortune.
Great perseverance brings misfortune.
.L 6 6
Horse and wagon part.
Bloody tears flow.
.H 4 "M\o'^e'ng" "Youthful Folly"
.X 4 6
.J
Youthful Folly has success.
It is not I who seek the young fool;
The young fool seeks me.
At the first oracle I inform him.
If he asks two or three times, it is importunity.
If he importunes, I give him no information.
Perseverance furthers.
.I
A spring wells up at the foot of the mountain:
The image of Youth.
Thus the superior man fosters his character
By thoroughness in all that he does.
.L 1 6
To make a fool develop
It furthers one to apply discipline.
The fetters should be removed.
To go on in this way brings humiliation.
.L 2 9 G
To bear with fools in kindliness brings good fortune.
To know how to take women
Brings good fortune.
The son is capable of taking charge of the household.
.L 3 6
Take not a maiden who, when she sees a man of bronze,
Loses possession of herself.
Nothing furthers.
.L 4 6
Entangled folly brings humiliation.
.L 5 6 G
Childlike folly brings good fortune.
.L 6 9
In punishing folly
It does not further one
To commit transgressions.
The only thing that furthers
Is to prevent transgressions.
.H 5 "Hsu" "Waiting (Nourishment)"
.X 6 1
.J
Waiting. If you are sincere,
You have light and success.
Perseverance brings good fortune.
It furthers one to cross the great water.
.I
Clouds rise up to heaven:
The image of Waiting.
Thus the superior man eats and drinks,
Is joyous and of good cheer.
.L 1 9
Waiting in the meadow.
It furthers one to abide in what endures.
No blame.
.L 2 9
Waiting on the sand.
There is some gossip.
The end brings good fortune.
.L 3 9
Waiting in the mud
Brings about the arrival of the enemy.
.L 4 6
Waiting in blood.
Get out of the pit.
.L 5 9 G
Waiting at meat and drink.
Perseverance brings good fortune.
.L 6 6
One falls into the pit.
Three uninvited guests arrive.
Honor them, and in the end there will be good fortune.
.H 6 "Sung" "Conflict"
.X 1 6
.J
Conflict. You are sincere
And are being obstructed.
A cautious halt halfway brings good fortune.
Going through to the end brings misfortune.
It furthers one to see the great man.
It does not further one to cross the great water.
.I
Heaven and water go their opposite ways:
The image of Conflict.
Thus in all his transactions the superior man
Carefully considers the beginning.
.L 1 6
If one does not perpetuate the affair,
There is a little gossip.
In the end, good fortune comes.
.L 2 9
One cannot engage in conflict;
One returns home, gives way.
The people of his town,
Three hundred households,
Remain free of guilt.
.L 3 6
To nourish oneself on ancient virtue induces perseverance.
Danger. In the end, good fortune comes.
If by chance you are in the service of a king,
Seek not works.
.L 4 9
One cannot engage in conflict.
One turns back and submits to fate,
Changes one's attitude,
And finds peace in perseverance.
Good fortune.
.L 5 9 G
To contend before him
Brings supreme good fortune.
.L 6 9
Even if by chance a leather belt is bestowed on one,
By the end of a morning
It will have been snatched away three times.
.H 7 "Shih" "The Army"
.X 8 6
.J
The Army. The army needs perseverance
And a strong man.
Good fortune without blame.
.I
In the middle of the earth is water:
The image of the Army.
Thus the superior man increases his masses
By generosity toward the people.
.L 1 6
An army must set forth in proper order.
If the order is not good, misfortune threatens.
.L 2 9 G
In the midst of the army.
Good fortune. No blame.
The king bestows a triple decoration.
.L 3 6
Perchance the army carries corpses in the wagon.
Misfortune.
.L 4 6
The army retreats. No blame.
.L 5 6 G
There is game in the field.
It furthers one to catch it.
Without blame.
Let the eldest lead the army.
The younger transports corpses;
Then perseverance brings misfortune.
.L 6 6
The great prince issues commands,
Founds states, vests families with fiefs.
Inferior people should not be employed.
.H 8 "Pi" "Holding Together [Union]"
.X 6 8
.J
Holding Together brings good fortune.
Inquire of the oracle once again
Whether you possess sublimity, constancy, and perseverance;
Then there is no blame.
Those who are uncertain gradually join.
Whoever comes too late
Meets with misfortune.
.I
On the earth is water:
The image of Holding Together.
Thus the kings of antiquity
Bestowed the different states as fiefs
And cultivated friendly relations
With the feudal lords.
.L 1 6
Hold to him in truth and loyalty;
This is without blame.
Truth, like a full earthen bowl:
Thus in the end
Good fortune comes from without.
.L 2 6
Hold to him inwardly.
Perseverance brings good fortune.
.L 3 6
You hold together with the wrong people.
.L 4 6
Hold to him outwardly also.
Perseverance brings good fortune.
.L 5 9 G
Manifestation of holding together.
In the hunt the king uses beaters on three sides only
And foregoes game that runs off in front.
The citizens need no warning.
Good fortune.
.L 6 6
He finds no head for holding together.
Misfortune.
.H 9 "Hsiao Ch\'u" "The Taming Power of the Small"
.X 2 1
.J
The Taming Power of the Small
Has success.
Dense clouds, no rain from our western region.
.I
The wind drives across heaven:
The image of the Taming Power of the Small.
Thus the superior man
Refines the outward aspect of his nature.
.L 1 9
Return to the way.
How could there be blame in this?
Good fortune.
.L 2 9
He allows himself to be drawn into returning.
Good fortune.
.L 3 9
The spokes burst out of the wagon wheels.
Man and wife roll their eyes.
.L 4 6 C
If you are sincere, blood vanishes and fear gives way.
No blame.
.L 5 9 G
If you are sincere and loyally attached,
You are rich in your neighbor.
.L 6 9
The rain comes, there is rest.
This is due to the lasting effect of character.
Perseverance brings the woman into danger.
The moon is nearly full.
If the superior man persists,
Misfortune comes.
.H 10 "Lu" "Treading [Conduct]"
.X 1 5
.J
Treading. Treading upon the tail of the tiger.
It does not bite the man. Success.
.I
Heaven above, the lake below:
The image of Treading.
Thus the superior man discriminates between high and low,
And thereby fortifies the thinking of the people.
.L 1 9
Simple conduct. Progress without blame.
.L 2 9
Treading a smooth, level course.
The perseverance of a dark man
Brings good fortune.
.L 3 6 C
A one-eyed man is able to see,
A lame man is able to tread.
He treads on the tail of the tiger.
The tiger bites the man.
Misfortune.
Thus does a warrior act on behalf of his great prince.
.L 4 9
He treads on the tail of the tiger.
Caution and circumspection
Lead ultimately to good fortune.
.L 5 9 G
Resolute conduct.
Perseverance with awareness of danger.
.L 6 9
Look to your conduct and weigh the favorable signs.
When everything is fulfilled, supreme good fortune comes.
.H 11 "T\'ai" "Peace"
.X 8 1
.J
Peace. The small departs,
The great approaches.
Good fortune. Success.
.I
Heaven and earth unite: the image of Peace.
Thus the ruler
Divides and completes the course of heaven and earth;
He furthers and regulates the gifts of heaven and earth,
And so aids the people.
.L 1 9
When ribbon grass is pulled up, the sod comes with it.
Each according to his kind.
Undertakings bring good fortune.
.L 2 9 G
Bearing with the uncultured in gentleness,
Fording the river with resolution,
Not neglecting what is distant,
Not regarding one's companions:
Thus one may manage to walk in the middle.