package elm_playground_gamekits

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file Push.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(* Claude Code
 *
 * Copyright (C) 2026 Yoann Padioleau
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License
 * (LGPL) as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *)

(* See Push.mli *)

let chain ~(blocked : int * int -> bool) ~(pushable : int * int -> bool) ?(limit = max_int) ((c, r) : int * int) ((dc, dr) : int * int) : (int * int) list option =
  let rec walk (c, r) acc =
    let next = (c + dc, r + dr) in
    if pushable next then walk next (next :: acc)
    else if blocked next || List.length acc > limit then None
    else Some (List.rev acc)
  in
  walk (c, r) []