This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplier x do &(&1*x) end | |
def multiplier2 x do | |
fn(y) -> | |
y * x | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial 0 do 1 end | |
def factorial n do n * factorial(n-1) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum 1 do 1 end | |
def sum n do n + sum (n - 1) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gcd x,0 do x end | |
def gcd x,y do gcd y, rem(x,y) end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp midpoint a,b do div(a+b,2) end | |
def guess(my_choice, a.._) when my_choice == a do IO.puts "is it #{a}?" end | |
def guess(my_choice, _..b) when my_choice == b do IO.puts "is it #{b}?" end | |
def guess(my_choice, a.._) when my_choice < a do IO.puts "out of range" end | |
def guess(my_choice, _..b) when my_choice > b do IO.puts "out of range" end | |
def guess(my_choice, a..b) when my_choice > div((a+b),2) do | |
IO.puts "is it #{midpoint(a,b)}?" | |
guess my_choice, midpoint(a,b)..b | |
end | |
def guess(my_choice, a..b) when my_choice < div((a+b),2) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min [] do 0 end | |
def min [h|t] do _min [h|t],h end | |
defp _min [],smallest do smallest end | |
defp _min [h|t], smallest do | |
cond do | |
smallest <= h -> | |
_min t, smallest | |
smallest >= h -> | |
_min t, h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ember new hello-world | |
cd hello-world | |
ember install ember-electron | |
ember electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
actions: { | |
sayHello(){ | |
alert ("Hello"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
someArray: Ember.A([3,2,4,1]), | |
maxNumber: Ember.computed.max('someArray'), | |
newNumber: 5, | |
actions: { | |
insertNumber(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
articles: Ember.A([ | |
Ember.Object.create({title:'title 1',status:'active'}), | |
Ember.Object.create({title:'title 2',status:'draft'}), | |
Ember.Object.create({title:'title 3',status:'draft'}), | |
Ember.Object.create({title:'title 4',status:'draft'}), | |
Ember.Object.create({title:'title 5',status:'active'}), |