Biorhythms: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
No edit summary |
||
Line 1,871: | Line 1,871: | ||
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|Red}}== |
|||
{{trans|Raku}} |
|||
<syntaxhighlight lang="Red"> |
|||
Red [ |
|||
Title: "Biorythms" |
|||
Source: https://rosettacode.org/wiki/Biorhythms#Red |
|||
Purpose: "Calculates biorythmic values for given birthday and target date" |
|||
] |
|||
biorythms: function [ |
|||
"Calculates biorythmic values for given birthday and target date" |
|||
bday [date!] |
|||
target [date!] |
|||
][ |
|||
cycles: [ |
|||
"Physical day " 23 |
|||
"Emotional day " 28 |
|||
"Mental day " 33 |
|||
] |
|||
quadrants: [ |
|||
["(up and rising" "peak"] |
|||
["(up but falling" "transition"] |
|||
["(down and falling" "valley"] |
|||
["(down but rising" "transition"] |
|||
] |
|||
days: target - bday |
|||
print [ |
|||
#"^(line)" |
|||
"Birthday :" bday #"^(line)" |
|||
"Target date:" target #"^(line)" |
|||
"Days :" days "days" |
|||
] |
|||
foreach [cycle len] cycles [ |
|||
posn: days % len |
|||
quadrant: to-integer ((posn / len * 4) + 1) |
|||
ampl: to-percent round/to sin (days / len * 2 * pi) 0.01 |
|||
trend: quadrants/(quadrant) |
|||
case [ |
|||
ampl > 0.95 [desc: " Peak"] |
|||
ampl < -0.95 [desc: " Valley"] |
|||
(absolute ampl) <= 0.05 [desc: " Critical transition"] |
|||
true [ |
|||
t: to-integer (quadrant / 4 * len) - posn |
|||
desc: reduce [pad/left ampl 4 trend/(1) ", next" trend/(2) "in" t "days)"] |
|||
] |
|||
] |
|||
print [cycle pad/left reduce [posn "of" len] 8 ":" desc] |
|||
] |
|||
] |
|||
biorythms 1943-03-09 1972-07-11 ; Bobby Fisher won the World Chess Championship |
|||
biorythms 1987-05-22 2023-01-29 ; Novak Đoković won the Australian Open for the 11th time |
|||
biorythms 1969-01-03 2013-09-13 ; Michael Schuhmacher's bad skiing accident |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Birthday : 9-Mar-1943 |
|||
Target date: 11-Jul-1972 |
|||
Days : 10717 days |
|||
Physical day 22 of 23 : -27% (down but rising , next transition in 1 days) |
|||
Emotional day 21 of 28 : Valley |
|||
Mental day 25 of 33 : Valley |
|||
Birthday : 22-May-1987 |
|||
Target date: 29-Jan-2023 |
|||
Days : 13036 days |
|||
Physical day 18 of 23 : Valley |
|||
Emotional day 16 of 28 : -43% (down and falling , next valley in 5 days) |
|||
Mental day 1 of 33 : 19% (up and rising , next peak in 7 days) |
|||
Birthday : 3-Jan-1969 |
|||
Target date: 13-Sep-2013 |
|||
Days : 16324 days |
|||
Physical day 17 of 23 : Valley |
|||
Emotional day 0 of 28 : Critical transition |
|||
Mental day 22 of 33 : -87% (down and falling , next valley in 2 days) |
|||
</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, |