Is there a way to write a function into JLD or other h5 file?

I know BSON works if you make your function an anonymous function:

using BSON
f = x -> x^2
@save "f.bson" f
# in new session
BSON.@load "f.bson" f
f(3) # 9

although it can’t have keyword arguments. I don’t think JLD2 works with any unfortunately, but maybe its in the works.

1 Like