An warware: fibonacci

Fibonacci jerin, jerin abubuwan da ke jan hankalin masana kimiyya da masu ilimin lissafi na ฦ™arni, kuma an ษ—aure su tam tare da kayan ado, ana amfani da su a cikin nau'ikan kyawawan kyakkyawa - salo da fasaha. Jerin lambobi ne inda ake samun lamba ta gaba ta hanyar ฦ™ara lambobi biyu da ke gabansa, farawa da 0 da 1. Wannan jeri yana nunawa a cikin sifofin halitta kamar karkatar da harsashi, lanฦ™wasa raฦ™uman ruwa, buษ—e ganye, da dai sauransu. na halitta alamu.

A cikin shirye-shirye, jerin Fibonacci suna magance ra'ayoyi gama gari kamar iterations, maimaitawa da haษ“akawa cikin sarฦ™aฦ™ฦ™iya a hankali, yin aiki a matsayin babban ginshiฦ™i don dabarun ฦ™ididdigewa da ci gaba. Kamar a cikin salon, inda yanayi daban-daban ke motsawa da fita amma wasu alamu sun yi rinjaye, hanyoyin samar da shirye-shirye suna da halaye iri ษ—aya. Kuma Haskell, yaren shirye-shirye ne kawai mai aiki, yana ba da wasu musamman kuma ingantattun hanyoyi don sarrafa jerin Fibonacci.

Kwamfuta Fibonacci ta hanyar Haskell

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

Wannan shi ne mafi aiwatar da kai tsaye na Fibonacci jerin a cikin Haskell, wanda ya dace da ma'anar lissafinsa kai tsaye. Yana amfani da mahimmancin ra'ayi a cikin shirye-shiryen aiki - maimaitawa. Koyaya, wannan lambar ba ta da inganci ga manyan lambobi saboda ฦ™ididdige ฦ™ididdiga masu yawa na ฦ™imar iri ษ—aya.

Inganta ฦ˜warewa tare da Memoization

import Data.Map (Map, lookup, insert, fromList)

memoize :: (Integer -> Integer) -> (Integer -> Integer)
memoize f = lookupAndInsert
    where
    lookupAndInsert :: Integer -> Integer
    lookupAndInsert x = case lookup x table of
        Just v  -> v
        Nothing -> f x

    table :: Map Integer Integer
    table = fromList $ map (x -> (x, f x)) [0 .. upperLimit]

fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

main :: IO ()
main = print $ memoize fib 30

Anan ga ingantaccen maganin matsalar mu ta amfani tunawa dabara, sau da yawa ana amfani da su a cikin harsuna masu aiki kamar Haskell. Wannan lambar tana adana ฦ™imar ฦ™ididdiga a cikin tebur kuma ta bincika wannan tebur kafin gudanar da aikin maimaitawa - idan an ฦ™ididdige ฦ™imar, kawai yana dawo da ฦ™imar daga tebur maimakon sake gudanar da lissafin.

Yanzu bari mu ci gaba mu ga yadda za mu iya zana daidaici tsakanin Fibonacci jerin da fashion duniya.

Golden Ratio da Fashion

Lambobin Fibonacci, ta hanyar rabon zinare da suke ginawa, suna ba da kaso mai ban sha'awa mai suna Golden Ratio. Wannan Girman Zinare (1.618:1) yana da daษ—i da kyau kuma ya fito cikin salo, ฦ™irar gine-gine da yanayi.

A cikin salon zamani na zamani, kunkuntar waistline ta faษ—o zuwa cikakkiyar kwatangwalo mai kama da Fibonacci Spiral. The Tufafin A-line, bin irin wannan tsari, yana kara tsayin jiki kuma yana kunkuntar kugu, alamar kasancewar Fibonacci akan titin jirgin sama. Har wala yau, masu zanen kaya suna amfani da wannan rabo a sane ko a cikin ษ“angarorin su don ฦ™irฦ™irar kamanni masu kyan gani da jituwa.

Lambar Launi na Fashion

Launuka suna taka muhimmiyar rawa a cikin salon, tare da haษ—uwa sau da yawa suna bin jerin Fibonacci. Kaya mai sauฦ™i na iya biyo baya a 1: 1: 2 haษ—uwa, inda jaket da wando ke raba launi, kuma riga da kayan haษ—i suna madubi juna. Ko, yi amfani da haษ—in 2:3:5 don haษ—in kai mai sassa uku. Ana iya lura da wannan ka'ida ta fannoni da yawa na salon salo.

Jin daษ—in jerin Fibonacci ba kawai game da fahimtar ilimin lissafi ko ฦ™ididdiga ba. Har ila yau, game da tsinkayar kyawawan alamu waษ—anda aka tsara ta wannan jeri, a cikin fasaha, salon zamani da kuma duniyar da ke kewaye da mu.

Shafi posts:

Leave a Comment