: ~/fs/Courses/cps506/w2019/Notes/Feb08 ; iex Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> 1+2 3 iex(2)> 1 < 4.0 true iex(3)> :atom :atom iex(4)> [[3,4],5,6] [[3, 4], 5, 6] iex(5)> [3,4|[5,6]] [3, 4, 5, 6] iex(6)> [3,4|5] [3, 4 | 5] iex(7)> a = [4,5,6] [4, 5, 6] iex(8)> a [4, 5, 6] iex(9)> a = [1,2,3] [1, 2, 3] iex(10)> {:valid,[h|t],x} = {:valid,a,:blat} {:valid, [1, 2, 3], :blat} iex(11)> h 1 iex(12)> t [2, 3] iex(13)> x :blat iex(14)> {:valid,[h|t],x} = {:valid,a} ** (MatchError) no match of right hand side value: {:valid, [1, 2, 3]} iex(14)> {:valid,[h|t],x} = {:valid,2,3} ** (MatchError) no match of right hand side value: {:valid, 2, 3} iex(14)> {:valid,[h|t],x} = {:valid,[2],3} {:valid, [2], 3} iex(15)> t [] iex(16)> {:valid,[h|t],x} = {:valid,[],3} ** (MatchError) no match of right hand side value: {:valid, [], 3} iex(16)> negate = fn x -> -x end #Function<6.99386804/1 in :erl_eval.expr/5> iex(17)> negate.(5) -5 iex(18)> c "foo.ex" [Foo] iex(19)> Foo.number(5) -5 iex(21)> Foo.number(5) -5 iex(22)> Foo.number(0) "zero" iex(24)> Foo.number(:bar) "blat" iex(25)> Enum.map(1..5,fn x -> x+6 end) '\a\b\t\n\v' iex(26)> Enum.map(300..305,fn x -> x+6 end) [306, 307, 308, 309, 310, 311] iex(27)> Enum.reduce(300..305,0,fn x,sum -> x+sum end) 1815 iex(28)> Enum.reduce(300..305,0,fn x,soFar -> x*soFar end) 0 iex(29)> Enum.reduce(300..305,1,fn x,soFar -> x*soFar end) 766144599696000 iex(30)> Enum.reduce(3000..3050,1,fn x,soFar -> x*soFar end) 3286488393053701380427940724328811803319608107691299953254989130208849033142219638248432842445838130320539876696997280800602864803950419963042862281844137673097216000000000000000 iex(31)> small = fn x -> x <300 end #Function<6.99386804/1 in :erl_eval.expr/5> iex(32)> small.(5) true iex(33)> small.(500) false iex(34)> Enum.filter(260..350,small) [260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299] iex(35)> Enum.take(260..350,5) [260, 261, 262, 263, 264] iex(36)> Enum.take_while([200,250,400,200],small) [200, 250] iex(37)>