Isoraqathedh

determine-dob wip 2

Feb 8th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 3.45 KB | None | 0 0
  1. (defparameter *chinese-new-years*
  2.   '((1924  2  5) (1925  1 24) (1926  2 13) (1927  2  2) (1928  1 22) (1929  2  9)
  3.     (1930  1 29) (1931  2 17) (1932  2  6) (1933  1 25) (1934  2 14) (1935  2  3)
  4.     (1936  1 24) (1937  2 11) (1938  1 31) (1939  2 19) (1940  2  8) (1941  1 27)
  5.     (1942  2 15) (1943  2  5) (1944  1 25) (1945  2 13) (1946  2  2) (1947  1 22)
  6.     (1948  2 10) (1949  1 29) (1950  2 17) (1951  2  6) (1952  1 27) (1953  2 14)
  7.     (1954  2  3) (1955  1 24) (1956  2 12) (1957  1 30) (1958  2 18) (1959  2  8)
  8.     (1960  1 28) (1961  2 15) (1962  2  5) (1963  1 25) (1964  2 13) (1965  2  2)
  9.     (1966  1 21) (1967  2  9) (1968  1 30) (1969  2 17) (1970  2  6) (1971  1 27)
  10.     (1972  2 15) (1973  2  3) (1974  1 23) (1975  2 11) (1976  1 31) (1977  2 18)
  11.     (1978  2  7) (1979  1 28) (1980  2 16) (1981  2  5) (1982  1 25) (1983  2 13)
  12.     (1984  2  2) (1985  2 20) (1986  2  9) (1987  1 29) (1988  2 17) (1989  2  6)
  13.     (1990  1 27) (1991  2 14) (1992  2  4) (1993  1 23) (1994  2 10) (1995  1 31)
  14.     (1996  2 19) (1997  2  7) (1998  1 28) (1999  2 16) (2000  2  5) (2001  1 24)
  15.     (2002  2 12) (2003  2  1) (2004  1 22) (2005  2  9) (2006  1 29) (2007  2 18)
  16.     (2008  2  7) (2009  1 26) (2010  2 14) (2011  2  3) (2012  1 23) (2013  2 10)
  17.     (2014  1 31) (2015  2 19) (2016  2  8) (2017  1 28) (2018  2 16) (2019  2  5)
  18.     (2020  1 25) (2021  2 12) (2022  2  1) (2023  1 22) (2024  2 10) (2025  1 29)
  19.     (2026  2 17) (2027  2  6) (2028  1 26) (2029  2 13) (2030  2  3) (2031  1 23)
  20.     (2032  2 11) (2033  1 31) (2034  2 19) (2035  2  8) (2036  1 28) (2037  2 15)
  21.     (2038  2  4) (2039  1 24) (2040  2 12) (2041  2  1) (2042  1 22) (2043  2 10))
  22.   "list of Chinese new years from 1924 to 2043 (two sexagenary cycles)")
  23. ;
  24. (defparameter *chinese-zodiac-names*
  25.   '("rat" "ox" "tiger" "rabbit" "dragon" "snake" "horse" "goat" "monkey" "rooster" "dog" "pig")
  26.   "List of Chinese zodiac animals, lines up with the above list , i.e. 1924 is RAT, 1925 is OX, etc.")
  27.  
  28. (defparameter *chinese-elements* '("metal" "wood" "water" "fire" "earth")
  29.   "List of Chinese animals, lines up with the above list, (rat 1924) is METAL etc.")
  30.  
  31. (defparameter *western-zodiac-month-boundaries*
  32.   '((3  21 "aries")     (4  21 "taurus")   (5  22 "gemini")
  33.     (6  22 "cancer")    (7  23 "leo")      (8  23 "virgo")
  34.     (9  23 "libra")     (10 23 "scorpio")  (11 23 "sagittarius")
  35.     (12 22 "capricorn") (1  21 "aquarius") (2  20 "pisces")))
  36. ;
  37.  
  38. (defparameter *western-zodiac-names*
  39.   '("aries" "taurus" "gemini" "cancer" "leo" "virgo" "libra" "scorpio" "sagittarius" "capricorn" "aquarius" "pisces"))
  40. ;
  41. (defun combine-dates (year-interval month-start)
  42.   (list (first year-interval) (first month-start) (second month-start)))
  43.  
  44. (defun next (i list)
  45.   (cond
  46.     ((> i (length list)) NIL)
  47.     ((< i 1) NIL)
  48.     ((= i (length list)) (first list))
  49.     (t (nth (1+ i) list))))
  50.  
  51. (defun chinese-new-years-given (zodiac-animal affilated-element) ;Read with the argument list
  52.   (loop
  53.        for i from 0 below (length *chinese-new-years*)
  54.        if (and (= (mod i (length *chinese-zodiac-names*))(position zodiac-animal *chinese-zodiac-names*))
  55.            (= (mod i (length *chinese-elements*))    (position affilated-element *chinese-elements*)))
  56.        collect (list (nth i *chinese-new-years*) (next i *chinese-new-years*))
  57.   ; {[chineseNewYears[i], next(chineseNewYears[i])] for i in range(len(chineseNewYears)) if ((i mod len(czn) == za and ((i mod len(ce) == ae))}
  58.   ))
Advertisement
Add Comment
Please, Sign In to add comment