Biorhythms: Difference between revisions
m
syntax highlighting fixup automation
Mickeywhite (talk | contribs) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 27:
Example run of my Raku implementation:
<
{{Out}}
Line 41:
{{trans|Python}}
<
‘
Print out biorhythm data for targetdate assuming you were
Line 84:
print(label‘ day ’position‘: ’description)
biorhythms(‘2043-03-09’, ‘2072-07-11’)</
{{out}}
Line 97:
=={{header|C}}==
{{trans|Locomotive Basic}}
<
#include <stdlib.h>
#include <math.h>
Line 127:
cycle(diff, 28, "Emotional");
cycle(diff, 33, "Intellectual");
}</
Test:
<
./cbio 1972 7 11 1943 3 9
Age: 10717 days
Physical cycle: -27%
Emotional cycle: -100%
Intellectual cycle: -100%</
=={{header|COBOL}}==
{{trans|Locomotive Basic}}
<
identification division.
Line 285:
.
</syntaxhighlight>
Test:
<
Compile and Test
C:\GnuCOBOL>
Line 296:
Physical 01:+027.0%
Emotional 14:+000.0% critical
Mental 03:+054.1%</
=={{header|Common Lisp}}==
{{trans|Locomotive Basic}}
<
;;; Get the days to J2000
Line 330:
(print-cycle diff 23 "physical")
(print-cycle diff 28 "emotional")
(print-cycle diff 33 "intellectual")))</
{{output}}
<pre>* (print-bio 1972 7 11 1943 3 9)
Line 342:
{{libheader| System.Math}}
{{Trans|Go}}
<
program Biorhythms;
Line 446:
CalcBiorhythms(datePairs[i, 0], datePairs[i, 1]);
readln;
end.</
=={{header|Emacs Lisp}}==
For Emacs, it makes sense to implement this as an interactive command which is personalized to the user's birthdate and computes the biorhythm for today. So if you put this code into your .emacs file (note that the birthdate has to be in MDY order in Emacs!):
<
(setq biorhythm-birthdate '(3 16 1953))
Line 464:
(* 2 pi diff (/ 1.0 x)))))) rhyt)))
(message "age: %i physical: %i%% emotional: %i%% intellectual: %i%%"
diff (car perc) (cadr perc) (caddr perc))))</
Then typing "M-x biorhythm" will produce this output in the Emacs echo area on 2022-04-21:
<pre>
Line 471:
=={{header|Factor}}==
<
math.constants math.functions ;
Line 492:
[ 33 "Mental" .day ] tri ;
"1809-02-12" "1863-11-19" .biorhythm</
{{out}}
<pre>
Line 504:
=={{header|FOCAL}}==
{{trans|Locomotive Basic}}
<
1.02 ASK Y,M,D
1.03 D 2; S BZ=Z
Line 530:
4.1 T " CRITICAL",!
5.1 T !</
{{output}}
<pre>*G
Line 547:
<
PROGRAM BIORHYTHM
C ------------------------------------------------------------------
Line 718:
RETURN
END</
{{in}}
Line 781:
=={{header|FreeBASIC}}==
{{trans|VBA}}
<
#define pi (4 * Atn(1))
Line 867:
Biorhythm("1809-02-12", "1863-11-19") 'correct DOB for Abraham Lincoln
Biorhythm("1809-01-12", "1863-11-19")
</syntaxhighlight>
=={{header|Go}}==
{{trans|Wren}}
<
import (
Line 943:
biorhythms(datePair[0], datePair[1])
}
}</
{{out}}
Line 968:
=={{header|J}}==
Let's presume the content of file <tt>br.ijs</tt> :
<syntaxhighlight lang=J>
use=: 'Use: ', (;:inv 2 {. ARGV) , ' YYYY-MM-DD YYYY-MM-DD'
Line 989:
exit 0
</syntaxhighlight>
Then bash commands could be
<pre>
Line 1,008:
=={{header|Julia}}==
{{trans|Raku}}
<
const cycles = ["Physical" => 23, "Emotional" => 28,"Mental" => 33]
Line 1,036:
tellfortune(Date("1809-01-12"), Date("1863-11-19"))
tellfortune(Date("1809-02-12"), Date("1863-11-19"))
</
<pre>
Born 1943-03-09, target date 1972-07-11
Line 1,059:
=={{header|Locomotive Basic}}==
<
20 gosub 1000
30 bday = day
Line 1,081:
2050 return
3000 if y < 1901 or y > 2099 then print "Year must be between 1901 and 2099!":run
3010 return</
{{out}}
<pre>Birthday (y,m,d) 1943,3,9
Line 1,093:
=={{header|Lua}}==
{{trans|Phix}}
<
lengths = {23, 28, 33}
quadrants = {
Line 1,154:
for i=1, #datePairs do
biorhythms(datePairs[i][1], datePairs[i][2])
end</
{{out}}
Line 1,182:
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<
birthdate = "1943-03-09";
targetdate //= DateObject;
Line 1,223:
,
{i, 3}
]</
{{out}}
<pre>Day 10717:
Line 1,232:
=={{header|Nim}}==
{{trans|Go}}
<
import strformat
import times
Line 1,293:
biorythms("1943-03-09", "1972-07-11")
biorythms("1809-01-12", "1863-11-19")
biorythms("1809-02-12", "1863-11-19")</
{{out}}
Line 1,316:
=={{header|Perl}}==
{{trans|Raku}}
<
use warnings;
use DateTime;
Line 1,350:
}
printf "%-13s %2d: %s", "$label day\n", $position, $description;
}</
{{out}}
<pre>Day 20003:
Line 1,359:
=={{header|Phix}}==
{{trans|Wren}}
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 1,402:
<span style="color: #0000FF;">}</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">datePairs</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span> <span style="color: #000000;">biorhythms</span><span style="color: #0000FF;">(</span><span style="color: #000000;">datePairs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">1</span><span style="color: #0000FF;">],</span> <span style="color: #000000;">datePairs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">])</span> <span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 1,427:
=={{header|Python}}==
<
"""
Line 1,492:
biorhythms("1943-03-09","1972-07-11")
</syntaxhighlight>
{{out}}
Line 1,506:
Also creates a plot showing past and future 30-day cycles
<
bDay <- as.Date(bDay)
targetDay <- as.Date(targetDay)
Line 1,548:
}
bioR('1943-03-09', '1972-07-11')</
{{out}}
Line 1,561:
=={{header|Raku}}==
<syntaxhighlight lang=raku
unit sub MAIN($birthday=%*ENV<BIRTHDAY>, $date = Date.today()) {
Line 1,597:
say "$label day $position: $description";
}
}</
{{Out}}
Line 1,620:
It is usual to use the birth date of a person.
<syntaxhighlight lang=text>/*REXX pgm shows the states of a person's biorhythms (physical, emotional, intellectual)*/
parse arg birthdate targetDate . /*obtain one or two dates from the C.L.*/
days= daysbet2(birthdate targetDate) /*invoke the 2nd version of a REXX pgm.*/
Line 1,642:
if x=pi * .5 then return 1; if x==pi*1.5 then return -1
if abs(x)=pi | x=0 then return 0; q= x*x; z= x
do k=2 by 2 until p=z; p= z; _= -_ *q/(k*k+k); z= z+_; end; return z</
{{out|output|text= when using the input of: <tt> 6/9/1946 </tt>}}
Line 1,652:
</pre>
=={{header|Ruby}}==
<
CYCLES = {physical: 23, emotional: 28, mental: 33}
Line 1,669:
biorhythms("1943-03-09", "1972-07-11")
</syntaxhighlight>
{{out}}
<pre>physical : cycle day 22, negative
Line 1,679:
{{works with|Wish}}
A graphing version using Tcl+Tk:
<
# Biorhythm calculator
set today [clock format [clock seconds] -format %Y-%m-%d ]
Line 1,747:
}
main {*}$argv</
{{Out}}
Output of <
https://i.imgur.com/U2izZOM.png
=={{header|VBA}}==
{{trans|Wren}}
<
'Jagged Array
Line 1,824:
Debug.Print ""
End Function</
{{Out}}
<pre>
Line 1,848:
=={{header|Vlang}}==
{{trans|Go}}
<
import math
Line 1,903:
biorhythms(date_pair[0], date_pair[1])?
}
}</
{{out}}
Line 1,930:
{{libheader|Wren-date}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 1,975:
["1809-02-12", "1863-11-19"] // correct DOB for Abraham Lincoln
]
for (datePair in datePairs) biorhythms.call(datePair[0], datePair[1])</
{{out}}
|