julia> foo(x,y) = reshape(collect(Iterators.product(x,y)), :, 1)
foo (generic function with 1 method)
julia> bar(x,y) = [(i,j) for j in y for i in x]
bar (generic function with 1 method)
julia> x = rand(100); y = rand(100);
julia> @btime foo($x,$y);
This file contains hidden or 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
VendorID | tpep_pickup_datetime | tpep_dropoff_datetime | passenger_count | trip_distance | RatecodeID | store_and_fwd_flag | PULocationID | DOLocationID | payment_type | fare_amount | extra | mta_tax | tip_amount | tolls_amount | improvement_surcharge | total_amount | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2018-12-01 00:28:22 | 2018-12-01 00:44:07 | 2 | 2.50 | 1 | N | 148 | 234 | 1 | 12 | 0.5 | 0.5 | 3.95 | 0 | 0.3 | 17.25 | |
1 | 2018-12-01 00:52:29 | 2018-12-01 01:11:37 | 3 | 2.30 | 1 | N | 170 | 144 | 1 | 13 | 0.5 | 0.5 | 2.85 | 0 | 0.3 | 17.15 | |
2 | 2018-12-01 00:12:52 | 2018-12-01 00:36:23 | 1 | .00 | 1 | N | 113 | 193 | 2 | 2.5 | 0.5 | 0.5 | 0 | 0 | 0.3 | 3.8 | |
1 | 2018-12-01 00:35:08 | 2018-12-01 00:43:11 | 1 | 3.90 | 1 | N | 95 | 92 | 1 | 12.5 | 0.5 | 0.5 | 2.75 | 0 | 0.3 | 16.55 | |
1 | 2018-12-01 00:21:54 | 2018-12-01 01:15:13 | 1 | 12.80 | 1 | N | 163 | 228 | 1 | 45 | 0.5 | 0.5 | 9.25 | 0 | 0.3 | 55.55 | |
1 | 2018-12-01 00:00:38 | 2018-12-01 00:29:26 | 1 | 18.80 | 1 | N | 132 | 97 | 1 | 50.5 | 0.5 | 0.5 | 10.35 | 0 | 0.3 | 62.15 | |
1 | 2018-12-01 00:59:39 | 2018-12-01 01:09:07 | 1 | 1.00 | 1 | N | 246 | 164 | 1 | 7.5 | 0.5 | 0.5 | 0.44 | 0 | 0.3 | 9.24 | |
1 | 2018-12-01 00:19:19 | 2018-12-01 00:22:19 | 1 | .30 | 1 | N | 161 | 163 | 4 | 4 | 0.5 | 0.5 | 0 | 0 | 0.3 | 5.3 |
This file contains hidden or 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
# start window number from 1 | |
set -g base-index 1 | |
# rebind prefix hot-key from C-b to C-j | |
set -g prefix C-j | |
unbind-key C-b | |
bind-key C-j send-prefix | |
# use vi binding | |
setw -g mode-keys vi |
This file contains hidden or 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
using Plots | |
function batman(; lw = 4) | |
let sqrt = x -> x > 0 ? Base.sqrt(x) : NaN | |
v1(x) = 2*sqrt(-abs(abs(x)-1)*abs(3-abs(x))/((abs(x)-1)*(3-abs(x)))) * (1+abs(abs(x)-3)/(abs(x)-3)) * sqrt(1-(x/7)^2)+(5+0.97(abs(x-.5)+abs(x+.5))-3(abs(x-.75)+abs(x+.75))) * (1+abs(1-abs(x))/(1-abs(x))) | |
v2(x) = (2.71052 + 1.5 - 0.5 * abs(x) - 1.35526 * sqrt(4-(abs(x)-1)^2)) * sqrt(abs(abs(x)-1)/(abs(x)-1)) + 0.9 | |
v3(x) = (-3)*sqrt(1-(x/7)^2)*sqrt(abs(abs(x)-4)/(abs(x)-4)) | |
v4(x) = abs(x/2)-0.0913722*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2) | |
x = -8:0.0005:8 |
From Mason Protter in Slack:
struct FullyCurried end
macro curried(fdef)
f = fdef.args[1].args[1]
fargs = fdef.args[1].args[2:end]
arity = length(fargs)
body = fdef.args[2]
julia> macro name(ex)
ex.head === :function ||
error("can be used for function defintions only")
name = ex.args[1].args[1]
assignment = :(local __NAME__ = $name)
pushfirst!(ex.args[2].args, assignment)
return ex
end
@name (macro with 1 method)
Functors are types that can be mapped over.
Two laws (https://wiki.haskell.org/Functor#Functor_Laws):
- mapping an identity function over a functor would return the same functor
- mapping function
g
thenf
is equivalent to mapping the composed function (f ∘ g)
fmap
is a mapping function that operates on functors. It can be defined for
specific objects so that the provided mapping function can be applied in the
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or 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
a | |
x | |
x | |
x | |
x | |
x | |
x | |
x | |
x | |
x |