Palindrome dates: Difference between revisions

(Added Quackery.)
Line 1,411:
9280-08-29
9290-09-29</pre>
 
=={{header|jq}}==
'''Adapted from [[#Wren|Wren]]'''
{{works with|jq}}
'''Also works with gojq, the Go implementation of jq'''
 
'''Also works with fq, a Go implementation of a large subset of jq'''
<syntaxhighlight lang=jq>
# input and output: [year, month, day] using month=1 for Jan
# add the number of days to the input date
def addDays($days):
. as [$y,$m,$d]
| [$y,$m-1,$d + $days,0,0,0,0,0] | mktime | gmtime[0:3] | .[1]+=1;
 
# input: [year, month, day], an array of integers
# output: [yyyy, mm, dd] , an array of strings,
def yyyymmdd:
def l($len): tostring | ($len - length) as $l | ("0" * $l)[:$l] + .;
[(.[0]|l(4)), (.[1]|l(2)), (.[2]|l(2))] ;
# input: [year, month, day] using month=1 for Jan
def isPalDate:
yyyymmdd | add | explode | . == reverse;
 
def task:
"The next 15 palindromic dates in yyyy-mm-dd format after 2020-02-02 are:",
( [2020, 2, 2]
| addDays(1)
| limit(15; recurse(addDays(1)) | select(isPalDate) )
| yyyymmdd
| join("-") );
 
task
</syntaxhighlight>
{{output}}
As for [[#Wren|Wren]].
 
 
=={{header|Julia}}==
2,489

edits