Biorhythms: Difference between revisions

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

edits