Functional Programming in Java, Second Edition: p 151 "func" instead of "memoizedFunction"

At 2/3rd of the page, we read;
Within the
computeMaxProfit()
method, we perform our task, and when it’s time to recurse we route the call tofunc
func
should be memoizedFunction
, as used in the example code.
This will return quickly if the value has been cached or memoized.
Aren’t those two words equivalent? So just:
This will return quickly if the value has been cached.
But one may want to note at the start of this chapter that “cached” and “memoized”/“memoing” are synonyms (I would say)
P.S.
The example code uses alternatingly length
and rodLength
as name for the input parameter; this should be unified.
In this case then one could write:
public int maxProfitMemoized(final int length) {
BiFunction<Function<Integer, Integer>, Integer, Integer> biFunction = this::computeMaxProfit;
return Memoizer.callMemoized(biFunction, length);
}
The above also emphasizes the fact that this::computeMaxProfit
actually maps to BiFunction<Function<Integer, Integer>, Integer, Integer>
, i.e. actually allows the compiler to create an anonymous implementation of BiFunction<Function<Integer, Integer>, Integer, Integer>
that calls this::computeMaxProfit
, something that is not entirely self-evident.
P.P.S.
In an article by David S. Warren, “Memoing for Logic Programs”, the following reference for “memoing” is given:
“Memo” Functions and Machine Learning
Popular Pragprog topics










Other popular topics









Latest in Pragprog
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /flutter
- /preact
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm