Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // type is: Cursor[List[T]] => List[U]
- function map_cursor_list (cur, f) {
- return map_indexed(cur.value, function (i, v) {
- return f(cur.refine(i));
- });
- }
- function map_indexed (list, f) {
- return map(zip(range(list.length), list), function (pair) {
- return f(pair[0], pair[1]);
- });
- }
- // type is Cursor[List[String]] => List[DOM.Input]
- map_cursor_list(form_cur, function (field_cur) {
- return <input type="text" value={field_cur.value} onChange={fieldCur.set} />;
- });
- // Or, do the refining and indexing by hand
- reduce(range(form_cur.value.length), function (acc, i) {
- var field_cur = form_cur.refine(i);
- return acc.push(<input type="text" value={field_cur.value} onChange={fieldCur.set} />);
- }, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement