You have to use 'DEFER:' ' Due to the way the parser works, words cannot be referenced before they are defined; that is, source files must order definitions in a strictly bottom-up fashion. Mutually-recursive pairs of words can be implemented by deferring one of the words in the pair allowing the second word in the pair to parse, then by defining the first word.
Examples DEFER: foe : fie ... foe ... ; : foe ... fie ... ; ' Cheers, Jon On Thu, Mar 28, 2019 at 3:19 PM Csóka Zoárd <csoka.zo...@gmail.com> wrote: > > I was wondering if factor supports indirect recursion or not. And if it's > possible to write indirectly recursive functions, how? > > I tried this code: > > : even ( n -- is-even? ) dup 0 = [ drop t ] [ 1 - odd ] if ; > : odd ( n -- is-odd? ) dup 0 = [ drop f ] [ 1 - even ] if ; > > But this didn't work this way. > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk