SlideShare a Scribd company logo
1 of 39
Download to read offline
Go Elixir
2018/6/14
Fukuoka.go#11
•
• Fusic
• Go Elixir React PHP 

• Twitter : @kobatako_
• Qiita : @kobatako
Elixir
Elixir
• 

• 

• 

Elixir
• 

Go
• 

Go
• 

Go
Elixir
• 

Go
• 

Go
• 

Go
🤔
※23
Elixir
Elixir
• Elixir
•
•
• Erlang VM
Go
func CalculateSleepTime(series map[string][]SleepTerm, results vital.SleeptimemeterResults) map[string][]SleepTerm {
var start time.Time
for _, value := range results.Data {
//
sleep, _ := time.Parse(datetimeFormat, value.SleepDatetime)
wakeup, _ := time.Parse(datetimeFormat, value.WakeupDatetime)
//
// 12
if isTimeAm(sleep) {
start = replaceTime(sleep.AddDate(0, 0, -1), 12, 0, 0)
// 12
} else {
start = replaceTime(sleep, 12, 0, 0)
}
//
startTime := sleep.Sub(start)
wakeupTime := wakeup.Sub(start)
series[start.Format(dateFormat)] =
append(series[start.Format(dateFormat)], SleepTerm{
Start: sleep,
Wakeup: wakeup,
StartTime: startTime,
WakeupTime: wakeupTime,
Duration: wakeup.Sub(sleep),
}
)
}
return series
}
Elixir
def calculate_sleep_time([data | tail], series) do
##
with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format),
{:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do
#
start =
if time_am?(sleep) do
# 12
Timex.shift(sleep, days: -1)
|> replace_time(12, 0, 0)
else
# 12
replace_time(12, 0, 0)
end
#
start_time = Timex.diff(sleep, start)
wakeup_time = Timex.diff(wakeup, start)
res_list = series ++ [{Timex.format!(start, @date_format), %{start: sleep, wakwup: wakeup,
start_time: start_time, wakeup_time: wakeup_time, duration: Timex.diff(wakeup,
sleep, :duration)}}]
calculate_sleep_time(tail, res_list)
end
end
// Go
sleep, _ := time.Parse(datetimeFormat, value.SleepDatetime)
wakeup, _ := time.Parse(datetimeFormat, value.WakeupDatetime)
# Elixir
with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format),
{:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do
#
end
•
• Elixir with
// Go
if isTimeAm(sleep) {
start = replaceTime(sleep.AddDate(0, 0, -1), 12, 0, 0)
} else {
start = replaceTime(sleep, 12, 0, 0)
}
# Elixir
start =
if time_am?(sleep) do
Timex.shift(sleep, days: -1) # Timex.shift
|> replace_time(12, 0, 0) # replace_time
else
replace_time(12, 0, 0)
end
• Elixir if
// Go
series[start.Format(dateFormat)] =
append(series[start.Format(dateFormat)], SleepTerm{
Start: sleep,
}
)
# Elixir
res_list = series ++ [
{Timex.format!(start, date_format), %{start: sleep }}
]
• ++
// Go
for _, value := range results.Data {
}
# Elixir
# data tail
def calculate_sleep_time([data | tail], series) do
with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format),
{:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do
calculate_sleep_time(tail, res_list)
end
end
•
// Go
return series
}
# Elixir
def calculate_sleep_time([], series) do
series
end
def calculate_sleep_time([data | tail], series) do
end
• return
Go
•
•
•
Go
•
• Json
•
Elixir
• Json
•
• 

Elixir
•
•
•
Go & Elixir
Go & Elixir
• 

•
• Go Elixir
•
Elixir
🤣
Go
&
※
GoとElixir、同時開発した時の気づき

More Related Content

What's hot

Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
Cloudflare
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
Alexander Mostovenko
 
Lua London Meetup 2013
Lua London Meetup 2013Lua London Meetup 2013
Lua London Meetup 2013
Cloudflare
 
証明駆動開発のたのしみ@名古屋reject会議
証明駆動開発のたのしみ@名古屋reject会議証明駆動開発のたのしみ@名古屋reject会議
証明駆動開発のたのしみ@名古屋reject会議
Hiroki Mizuno
 

What's hot (20)

Cluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in PracticeCluj Big Data Meetup - Big Data in Practice
Cluj Big Data Meetup - Big Data in Practice
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
 
Perl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReducePerl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReduce
 
SciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with AgilitySciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with Agility
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFx
 
ECMA Script
ECMA ScriptECMA Script
ECMA Script
 
Parallel Computing in R
Parallel Computing in RParallel Computing in R
Parallel Computing in R
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by example
 
Prgišče Lispa
Prgišče LispaPrgišče Lispa
Prgišče Lispa
 
Lua London Meetup 2013
Lua London Meetup 2013Lua London Meetup 2013
Lua London Meetup 2013
 
What's Special About Elixir
What's Special About ElixirWhat's Special About Elixir
What's Special About Elixir
 
Jk rubyslava 25
Jk rubyslava 25Jk rubyslava 25
Jk rubyslava 25
 
Elixir 5 minute intro
Elixir 5 minute introElixir 5 minute intro
Elixir 5 minute intro
 
"Metrics: Where and How", Vsevolod Polyakov
"Metrics: Where and How", Vsevolod Polyakov"Metrics: Where and How", Vsevolod Polyakov
"Metrics: Where and How", Vsevolod Polyakov
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 
証明駆動開発のたのしみ@名古屋reject会議
証明駆動開発のたのしみ@名古屋reject会議証明駆動開発のたのしみ@名古屋reject会議
証明駆動開発のたのしみ@名古屋reject会議
 
Rubyslava + PyVo #48
Rubyslava + PyVo #48Rubyslava + PyVo #48
Rubyslava + PyVo #48
 
Golang Channels
Golang ChannelsGolang Channels
Golang Channels
 
Go on!
Go on!Go on!
Go on!
 

Similar to GoとElixir、同時開発した時の気づき

ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
qmmr
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
偉格 高
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
isenbergwarne4100
 
The mighty js_function
The mighty js_functionThe mighty js_function
The mighty js_function
timotheeg
 

Similar to GoとElixir、同時開発した時の気づき (20)

Beyond the Callback: Yield Control with Javascript Generators
Beyond the Callback: Yield Control with Javascript GeneratorsBeyond the Callback: Yield Control with Javascript Generators
Beyond the Callback: Yield Control with Javascript Generators
 
"let ECMAScript = 6"
"let ECMAScript = 6" "let ECMAScript = 6"
"let ECMAScript = 6"
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Phoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってるPhoenix + Reactで 社内システムを 密かに作ってる
Phoenix + Reactで 社内システムを 密かに作ってる
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
ECMA5 and ES6 Promises
ECMA5 and ES6 PromisesECMA5 and ES6 Promises
ECMA5 and ES6 Promises
 
The mighty js_function
The mighty js_functionThe mighty js_function
The mighty js_function
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
Groovy
GroovyGroovy
Groovy
 
Django Celery
Django Celery Django Celery
Django Celery
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
 

More from Takahiro Kobaru (6)

Erlangでソフトウェアルータを作ってる話
Erlangでソフトウェアルータを作ってる話Erlangでソフトウェアルータを作ってる話
Erlangでソフトウェアルータを作ってる話
 
AppSyncをReactで使ってみた
AppSyncをReactで使ってみたAppSyncをReactで使ってみた
AppSyncをReactで使ってみた
 
SSOとか、SAMLとか、認証してみる
SSOとか、SAMLとか、認証してみるSSOとか、SAMLとか、認証してみる
SSOとか、SAMLとか、認証してみる
 
Mnesiaで分散ノードに入門してみた
Mnesiaで分散ノードに入門してみたMnesiaで分散ノードに入門してみた
Mnesiaで分散ノードに入門してみた
 
ReactでGraphQLを使っている
ReactでGraphQLを使っているReactでGraphQLを使っている
ReactでGraphQLを使っている
 
Elixir ライブラリ 「absinthe」でGraphQLに入門
Elixir ライブラリ 「absinthe」でGraphQLに入門Elixir ライブラリ 「absinthe」でGraphQLに入門
Elixir ライブラリ 「absinthe」でGraphQLに入門
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

GoとElixir、同時開発した時の気づき

  • 2. • • Fusic • Go Elixir React PHP 
 • Twitter : @kobatako_ • Qiita : @kobatako
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 15. 🤔
  • 16. ※23
  • 17.
  • 20.
  • 21. Go func CalculateSleepTime(series map[string][]SleepTerm, results vital.SleeptimemeterResults) map[string][]SleepTerm { var start time.Time for _, value := range results.Data { // sleep, _ := time.Parse(datetimeFormat, value.SleepDatetime) wakeup, _ := time.Parse(datetimeFormat, value.WakeupDatetime) // // 12 if isTimeAm(sleep) { start = replaceTime(sleep.AddDate(0, 0, -1), 12, 0, 0) // 12 } else { start = replaceTime(sleep, 12, 0, 0) } // startTime := sleep.Sub(start) wakeupTime := wakeup.Sub(start) series[start.Format(dateFormat)] = append(series[start.Format(dateFormat)], SleepTerm{ Start: sleep, Wakeup: wakeup, StartTime: startTime, WakeupTime: wakeupTime, Duration: wakeup.Sub(sleep), } ) } return series }
  • 22. Elixir def calculate_sleep_time([data | tail], series) do ## with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format), {:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do # start = if time_am?(sleep) do # 12 Timex.shift(sleep, days: -1) |> replace_time(12, 0, 0) else # 12 replace_time(12, 0, 0) end # start_time = Timex.diff(sleep, start) wakeup_time = Timex.diff(wakeup, start) res_list = series ++ [{Timex.format!(start, @date_format), %{start: sleep, wakwup: wakeup, start_time: start_time, wakeup_time: wakeup_time, duration: Timex.diff(wakeup, sleep, :duration)}}] calculate_sleep_time(tail, res_list) end end
  • 23. // Go sleep, _ := time.Parse(datetimeFormat, value.SleepDatetime) wakeup, _ := time.Parse(datetimeFormat, value.WakeupDatetime) # Elixir with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format), {:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do # end • • Elixir with
  • 24. // Go if isTimeAm(sleep) { start = replaceTime(sleep.AddDate(0, 0, -1), 12, 0, 0) } else { start = replaceTime(sleep, 12, 0, 0) } # Elixir start = if time_am?(sleep) do Timex.shift(sleep, days: -1) # Timex.shift |> replace_time(12, 0, 0) # replace_time else replace_time(12, 0, 0) end • Elixir if
  • 25. // Go series[start.Format(dateFormat)] = append(series[start.Format(dateFormat)], SleepTerm{ Start: sleep, } ) # Elixir res_list = series ++ [ {Timex.format!(start, date_format), %{start: sleep }} ] • ++
  • 26. // Go for _, value := range results.Data { } # Elixir # data tail def calculate_sleep_time([data | tail], series) do with {:ok, sleep} <- Timex.parse(data.sleep_datetime, @datetime_format), {:ok, wakeup} <- Timex.parse(data.wakeup_datetime, @datetime_format) do calculate_sleep_time(tail, res_list) end end •
  • 27. // Go return series } # Elixir def calculate_sleep_time([], series) do series end def calculate_sleep_time([data | tail], series) do end • return
  • 28.
  • 34. Go & Elixir • 
 • • Go Elixir •
  • 37. &
  • 38.