Code Duplication    Length = 11-11 lines in 2 locations

src/list.php 2 locations

@@ 146-156 (lines=11) @@
143
 * @param  array|string $list
144
 * @return mixed
145
 */
146
function head() {
147
    static $head = false;
148
    $head = $head ?: curry(function($list) {
149
        if(is_string($list))
150
            return substr($list, 0, 1);
151
        return (count($list) > 0)
152
            ? $list[0]
153
            : null;
154
    });
155
    return _apply($head, func_get_args());
156
}
157
158
/**
159
 * Returns the last item of the given array or string.
@@ 174-184 (lines=11) @@
171
 * @param  array|string $list
172
 * @return mixed
173
 */
174
function last () {
175
    static $last = false;
176
    $last = $last ?: curry(function($list) {
177
        if(is_string($list))
178
            return substr($list, -1);
179
        return (count($list) > 0)
180
            ? $list[count($list) - 1]
181
            : null;
182
    });
183
    return _apply($last, func_get_args());
184
}
185
186
/**
187
 * Returns all but the last element of the given array or string.