Biorhythms: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
||
Line 27: | Line 27: | ||
Example run of my Raku implementation: |
Example run of my Raku implementation: |
||
<syntaxhighlight lang=sh>raku br.raku 1943-03-09 1972-07-11</syntaxhighlight> |
<syntaxhighlight lang="sh">raku br.raku 1943-03-09 1972-07-11</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Line 37: | Line 37: | ||
Double valley! This was apparently not a good day for Mr. Fischer to begin a chess tournament... |
Double valley! This was apparently not a good day for Mr. Fischer to begin a chess tournament... |
||
=={{header|11l}}== |
=={{header|11l}}== |
||
{{trans|Python}} |
{{trans|Python}} |
||
<syntaxhighlight lang=11l>F biorhythms(birthdate_str, targetdate_str) |
<syntaxhighlight lang="11l">F biorhythms(birthdate_str, targetdate_str) |
||
‘ |
‘ |
||
Print out biorhythm data for targetdate assuming you were |
Print out biorhythm data for targetdate assuming you were |
||
Line 94: | Line 93: | ||
Mental day 25: valley |
Mental day 25: valley |
||
</pre> |
</pre> |
||
=={{header|C}}== |
=={{header|C}}== |
||
{{trans|Locomotive Basic}} |
{{trans|Locomotive Basic}} |
||
<syntaxhighlight lang=c>#include <stdio.h> |
<syntaxhighlight lang="c">#include <stdio.h> |
||
#include <stdlib.h> |
#include <stdlib.h> |
||
#include <math.h> |
#include <math.h> |
||
Line 129: | Line 127: | ||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
Test: |
Test: |
||
<syntaxhighlight lang=bash>gcc -o cbio cbio.c -lm |
<syntaxhighlight lang="bash">gcc -o cbio cbio.c -lm |
||
./cbio 1972 7 11 1943 3 9 |
./cbio 1972 7 11 1943 3 9 |
||
Age: 10717 days |
Age: 10717 days |
||
Line 135: | Line 133: | ||
Emotional cycle: -100% |
Emotional cycle: -100% |
||
Intellectual cycle: -100%</syntaxhighlight> |
Intellectual cycle: -100%</syntaxhighlight> |
||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
{{trans|Locomotive Basic}} |
{{trans|Locomotive Basic}} |
||
<syntaxhighlight lang=cobol> |
<syntaxhighlight lang="cobol"> |
||
identification division. |
identification division. |
||
Line 287: | Line 284: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
Test: |
Test: |
||
<syntaxhighlight lang=bash> |
<syntaxhighlight lang="bash"> |
||
Compile and Test |
Compile and Test |
||
C:\GnuCOBOL> |
C:\GnuCOBOL> |
||
Line 297: | Line 294: | ||
Emotional 14:+000.0% critical |
Emotional 14:+000.0% critical |
||
Mental 03:+054.1%</syntaxhighlight> |
Mental 03:+054.1%</syntaxhighlight> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
{{trans|Locomotive Basic}} |
{{trans|Locomotive Basic}} |
||
<syntaxhighlight lang=lisp>;;;; Common Lisp biorhythms |
<syntaxhighlight lang="lisp">;;;; Common Lisp biorhythms |
||
;;; Get the days to J2000 |
;;; Get the days to J2000 |
||
Line 337: | Line 333: | ||
emotional cycle: -100% |
emotional cycle: -100% |
||
intellectual cycle: -100% </pre> |
intellectual cycle: -100% </pre> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
{{libheader| System.SysUtils}} |
{{libheader| System.SysUtils}} |
||
{{libheader| System.Math}} |
{{libheader| System.Math}} |
||
{{Trans|Go}} |
{{Trans|Go}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="delphi"> |
||
program Biorhythms; |
program Biorhythms; |
||
Line 447: | Line 442: | ||
readln; |
readln; |
||
end.</syntaxhighlight> |
end.</syntaxhighlight> |
||
=={{header|Emacs Lisp}}== |
=={{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!): |
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!): |
||
<syntaxhighlight lang=lisp>(require 'calendar) |
<syntaxhighlight lang="lisp">(require 'calendar) |
||
(setq biorhythm-birthdate '(3 16 1953)) |
(setq biorhythm-birthdate '(3 16 1953)) |
||
Line 469: | Line 463: | ||
age: 25238 physical: 94% emotional: 78% intellectual: -97% |
age: 25238 physical: 94% emotional: 78% intellectual: -97% |
||
</pre> |
</pre> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
<syntaxhighlight lang=factor>USING: calendar calendar.parser formatting io kernel math |
<syntaxhighlight lang="factor">USING: calendar calendar.parser formatting io kernel math |
||
math.constants math.functions ; |
math.constants math.functions ; |
||
Line 501: | Line 494: | ||
Mental day 5: 81.5%↑ |
Mental day 5: 81.5%↑ |
||
</pre> |
</pre> |
||
=={{header|FOCAL}}== |
=={{header|FOCAL}}== |
||
{{trans|Locomotive Basic}} |
{{trans|Locomotive Basic}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="focal">1.01 T "Enter birthdate (y,m,d)",! |
||
1.02 ASK Y,M,D |
1.02 ASK Y,M,D |
||
1.03 D 2; S BZ=Z |
1.03 D 2; S BZ=Z |
||
Line 541: | Line 533: | ||
Emotional cycle: =-100% |
Emotional cycle: =-100% |
||
Intellectual cycle: =-100%</pre> |
Intellectual cycle: =-100%</pre> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
Line 547: | Line 538: | ||
<syntaxhighlight lang= |
<syntaxhighlight lang="fortran">C ------------------------------------------------------------------ |
||
PROGRAM BIORHYTHM |
PROGRAM BIORHYTHM |
||
C ------------------------------------------------------------------ |
C ------------------------------------------------------------------ |
||
Line 775: | Line 766: | ||
E P : | M : | THR 84 |
E P : | M : | THR 84 |
||
===========================================================================</pre> |
===========================================================================</pre> |
||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
{{trans|VBA}} |
{{trans|VBA}} |
||
<syntaxhighlight lang=freebasic>#define floor(x) ((x*2.0-0.5) Shr 1) |
<syntaxhighlight lang="freebasic">#define floor(x) ((x*2.0-0.5) Shr 1) |
||
#define pi (4 * Atn(1)) |
#define pi (4 * Atn(1)) |
||
Line 868: | Line 855: | ||
Biorhythm("1809-01-12", "1863-11-19") |
Biorhythm("1809-01-12", "1863-11-19") |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
||
<syntaxhighlight lang=go>package main |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 965: | Line 950: | ||
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
||
</pre> |
</pre> |
||
=={{header|J}}== |
=={{header|J}}== |
||
Let's presume the content of file <tt>br.ijs</tt> : |
Let's presume the content of file <tt>br.ijs</tt> : |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="j"> |
||
use=: 'Use: ', (;:inv 2 {. ARGV) , ' YYYY-MM-DD YYYY-MM-DD' |
use=: 'Use: ', (;:inv 2 {. ARGV) , ' YYYY-MM-DD YYYY-MM-DD' |
||
Line 1,005: | Line 989: | ||
└──────────┴──────────────────────────────────────────┴──────────────────────────────────────────┘ |
└──────────┴──────────────────────────────────────────┴──────────────────────────────────────────┘ |
||
</pre> |
</pre> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
<syntaxhighlight lang=julia>using Dates |
<syntaxhighlight lang="julia">using Dates |
||
const cycles = ["Physical" => 23, "Emotional" => 28,"Mental" => 33] |
const cycles = ["Physical" => 23, "Emotional" => 28,"Mental" => 33] |
||
Line 1,056: | Line 1,039: | ||
Mental day 5: 81.5% (up and rising, next peak 1863-11-22) |
Mental day 5: 81.5% (up and rising, next peak 1863-11-22) |
||
</pre> |
</pre> |
||
=={{header|Locomotive Basic}}== |
=={{header|Locomotive Basic}}== |
||
<syntaxhighlight lang=locobasic>10 input "Birthday (y,m,d) ",y,m,d:gosub 3000 |
<syntaxhighlight lang="locobasic">10 input "Birthday (y,m,d) ",y,m,d:gosub 3000 |
||
20 gosub 1000 |
20 gosub 1000 |
||
30 bday = day |
30 bday = day |
||
Line 1,090: | Line 1,072: | ||
emotional cycle: -100% |
emotional cycle: -100% |
||
intellectual cycle: -100%</pre> |
intellectual cycle: -100%</pre> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
{{trans|Phix}} |
{{trans|Phix}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="lua">cycles = {"Physical day ", "Emotional day", "Mental day "} |
||
lengths = {23, 28, 33} |
lengths = {23, 28, 33} |
||
quadrants = { |
quadrants = { |
||
Line 1,180: | Line 1,161: | ||
Emotional day 24/28 : -78.2% (down but rising, next transition in 4 days) |
Emotional day 24/28 : -78.2% (down but rising, next transition in 4 days) |
||
Mental day 20/33 : -61.9% (down and falling, next transition in 4 days)</pre> |
Mental day 20/33 : -61.9% (down and falling, next transition in 4 days)</pre> |
||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="mathematica">targetdate = "1972-07-11"; |
||
birthdate = "1943-03-09"; |
birthdate = "1943-03-09"; |
||
targetdate //= DateObject; |
targetdate //= DateObject; |
||
Line 1,229: | Line 1,209: | ||
Emotional day 21: valley |
Emotional day 21: valley |
||
Mental day 25: valley</pre> |
Mental day 25: valley</pre> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="nim">import math |
||
import strformat |
import strformat |
||
import times |
import times |
||
Line 1,313: | Line 1,292: | ||
Emotional day 11: 62.3% (up but falling, next transition 1863-11-22) |
Emotional day 11: 62.3% (up but falling, next transition 1863-11-22) |
||
Mental day 5: 81.5% (up and rising, next peak 1863-11-22)</pre> |
Mental day 5: 81.5% (up and rising, next peak 1863-11-22)</pre> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
<syntaxhighlight lang=perl>use strict; |
<syntaxhighlight lang="perl">use strict; |
||
use warnings; |
use warnings; |
||
use DateTime; |
use DateTime; |
||
Line 1,356: | Line 1,334: | ||
Mental day 5: 81.4% (up and rising, next peak 1863-11-22) |
Mental day 5: 81.4% (up and rising, next peak 1863-11-22) |
||
Physical day 16: -94.2% (down and falling, next valley 1863-11-20)</pre> |
Physical day 16: -94.2% (down and falling, next valley 1863-11-20)</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
||
<!--<syntaxhighlight lang= |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<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> |
<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,423: | Line 1,400: | ||
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
||
</pre> |
</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
<syntaxhighlight lang=python> |
<syntaxhighlight lang="python"> |
||
""" |
""" |
||
Line 1,502: | Line 1,476: | ||
Mental day 25: valley |
Mental day 25: valley |
||
</pre> |
</pre> |
||
=={{header|R}}== |
=={{header|R}}== |
||
Also creates a plot showing past and future 30-day cycles |
Also creates a plot showing past and future 30-day cycles |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="r">bioR <- function(bDay, targetDay) { |
||
bDay <- as.Date(bDay) |
bDay <- as.Date(bDay) |
||
targetDay <- as.Date(targetDay) |
targetDay <- as.Date(targetDay) |
||
Line 1,559: | Line 1,532: | ||
Mental = 25: Down and rising |
Mental = 25: Down and rising |
||
</pre> |
</pre> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
<syntaxhighlight lang=raku line>#!/usr/bin/env raku |
<syntaxhighlight lang="raku" line>#!/usr/bin/env raku |
||
unit sub MAIN($birthday=%*ENV<BIRTHDAY>, $date = Date.today()) { |
unit sub MAIN($birthday=%*ENV<BIRTHDAY>, $date = Date.today()) { |
||
Line 1,607: | Line 1,579: | ||
Mental day 3: 54% (up and rising, next peak 1863-11-24) |
Mental day 3: 54% (up and rising, next peak 1863-11-24) |
||
</pre> |
</pre> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
The '''daysbet2''' (REXX program) is used (invoked on line '''3''' of this program) to calculate the number of days between two dates, |
The '''daysbet2''' (REXX program) is used (invoked on line '''3''' of this program) to calculate the number of days between two dates, |
||
Line 1,620: | Line 1,591: | ||
It is usual to use the birth date of a person. |
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)*/ |
<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.*/ |
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.*/ |
days= daysbet2(birthdate targetDate) /*invoke the 2nd version of a REXX pgm.*/ |
||
Line 1,652: | Line 1,623: | ||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="ruby">require 'date' |
||
CYCLES = {physical: 23, emotional: 28, mental: 33} |
CYCLES = {physical: 23, emotional: 28, mental: 33} |
||
Line 1,675: | Line 1,646: | ||
mental : cycle day 25, negative |
mental : cycle day 25, negative |
||
</pre> |
</pre> |
||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{works with|Wish}} |
{{works with|Wish}} |
||
A graphing version using Tcl+Tk: |
A graphing version using Tcl+Tk: |
||
<syntaxhighlight lang=tcl>#!/usr/bin/env wish |
<syntaxhighlight lang="tcl">#!/usr/bin/env wish |
||
# Biorhythm calculator |
# Biorhythm calculator |
||
set today [clock format [clock seconds] -format %Y-%m-%d ] |
set today [clock format [clock seconds] -format %Y-%m-%d ] |
||
Line 1,749: | Line 1,719: | ||
main {*}$argv</syntaxhighlight> |
main {*}$argv</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Output of <syntaxhighlight lang=sh>wish br.wish 1809-02-12 1863-11-19</syntaxhighlight> - Lincoln's biorhythms at Gettysburg: |
Output of <syntaxhighlight lang="sh">wish br.wish 1809-02-12 1863-11-19</syntaxhighlight> - Lincoln's biorhythms at Gettysburg: |
||
https://i.imgur.com/U2izZOM.png |
https://i.imgur.com/U2izZOM.png |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
{{trans|Wren}} |
{{trans|Wren}} |
||
<syntaxhighlight lang=vb>Function Biorhythm(Birthdate As Date, Targetdate As Date) As String |
<syntaxhighlight lang="vb">Function Biorhythm(Birthdate As Date, Targetdate As Date) As String |
||
'Jagged Array |
'Jagged Array |
||
Line 1,845: | Line 1,814: | ||
Mental day 3 : 54.1% (up and rising, next peak 24.11.1863) |
Mental day 3 : 54.1% (up and rising, next peak 24.11.1863) |
||
</pre> |
</pre> |
||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
<syntaxhighlight lang=vlang>import time |
<syntaxhighlight lang="vlang">import time |
||
import math |
import math |
||
Line 1,925: | Line 1,893: | ||
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
Mental day 5 : 81.4% (up and rising, next peak 1863-11-22) |
||
</pre> |
</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
{{libheader|Wren-date}} |
{{libheader|Wren-date}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
<syntaxhighlight lang=ecmascript>import "/date" for Date |
<syntaxhighlight lang="ecmascript">import "/date" for Date |
||
import "/fmt" for Fmt |
import "/fmt" for Fmt |
||