recursive-hashcode ( n obj quot -- code ) (original) (raw)

recursive-hashcode ( n obj quot -- code )

Vocabulary
math

Inputs

n an integer
obj an object
quot a quotation with stack effect ( n obj -- code )

Outputs

code an integer

Word description
A combinator used to implement methods for the hashcode* generic word. If n is less than or equal to zero, outputs 0, otherwise calls the quotation.

Definition

USING: kernel ;

IN: math

: recursive-hashcode ( n obj quot -- code )
pick 0 <= [ 3drop 0 ] [ [ 1 - ] 2dip call ] if ; inline