Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // type is: Cursor[List[T]] => List[U]
  2. function map_cursor_list (cur, f) {
  3. return map_indexed(cur.value, function (i, v) {
  4. return f(cur.refine(i));
  5. });
  6. }
  7.  
  8. function map_indexed (list, f) {
  9. return map(zip(range(list.length), list), function (pair) {
  10. return f(pair[0], pair[1]);
  11. });
  12. }
  13.  
  14. // type is Cursor[List[String]] => List[DOM.Input]
  15. map_cursor_list(form_cur, function (field_cur) {
  16. return <input type="text" value={field_cur.value} onChange={fieldCur.set} />;
  17. });
  18.  
  19.  
  20. // Or, do the refining and indexing by hand
  21. reduce(range(form_cur.value.length), function (acc, i) {
  22. var field_cur = form_cur.refine(i);
  23. return acc.push(<input type="text" value={field_cur.value} onChange={fieldCur.set} />);
  24. }, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement