whisperedcigar has quit [Ping timeout: 245 seconds]
vramana has joined #ocaml
noddy2OOO has joined #ocaml
copy` has quit [Quit: Connection closed for inactivity]
sz0 has joined #ocaml
chetshah_ has joined #ocaml
Simn has joined #ocaml
MercurialAlchemi has joined #ocaml
troydm has joined #ocaml
chetshah_ has quit [Ping timeout: 260 seconds]
ryanartecona has quit [Quit: ryanartecona]
madroach has quit [Quit: leaving]
programo has quit [Remote host closed the connection]
argent_smith has joined #ocaml
ziyourenxiang has quit [Quit: Leaving]
infinity0 has quit [Remote host closed the connection]
scitesy has joined #ocaml
slash^ has joined #ocaml
infinity0 has joined #ocaml
zirman has joined #ocaml
scitesy has quit [Read error: No route to host]
scitesy has joined #ocaml
zirman has quit [Ping timeout: 256 seconds]
infinity0 has quit [Ping timeout: 264 seconds]
whisperedcigar has joined #ocaml
rgrinberg has quit [Ping timeout: 250 seconds]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
whisperedcigar has quit [Ping timeout: 245 seconds]
whisperedcigar has joined #ocaml
zirman has joined #ocaml
whisperedcigar has quit [Client Quit]
zirman has quit [Ping timeout: 265 seconds]
larhat has joined #ocaml
trepta7 has joined #ocaml
tmtwd has quit [Quit: Leaving]
Flerex has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 258 seconds]
jnavila has joined #ocaml
Simn has quit [Quit: Leaving]
trepta7 has quit [Ping timeout: 258 seconds]
Muzer has quit [Ping timeout: 264 seconds]
michbad has joined #ocaml
<Flerex>
Hello.
<Flerex>
I'm trying to create a function that given a list of a single pair [(x,y)] generates all possible paths.
<Flerex>
To do this I'm trying to use a function that I have already created that receives a list of pairs, gets the head one, computes all possible next pairs for the head, and returns a list of lists where the lists are just the previous list with all possible next pairs prepended, or an empty list if there's no possible next element for the given list of pairs.
<Flerex>
For example, if the next possible elements for (1,2) are (3,4) and (5,6), this function would receive a list as [(1,2);(8,9);...] and would return [[(3,4);(1,2);(8,9);...];[(5,6);(1,2);(8,9);...]].
<Flerex>
If the possible next pairs is any, it would return [].
<Flerex>
My problem is that I can't think of a function that does this kind of recursivity with all possible paths until the head of a path returns no next pair. Can anyone help me?
<Flerex>
If it's of any help, the code for this function that creates a path with the next element (if any) is: http://pastebin.com/4KNF8s7n
zirman has joined #ocaml
octachron has joined #ocaml
zirman has quit [Ping timeout: 256 seconds]
<lyxia>
do you have to use that function
<Flerex>
No, I thought it would make thinks easier but it's not compulsory.
<Flerex>
things*
<lyxia>
So, l is a list of pairs, and possible_squares_by_path computes the possible new elements to append?
edwin has left #ocaml [#ocaml]
<Flerex>
I'm sorry, the function that I described is this one, the one you're talking about: http://pastebin.com/qwtvHS5i
<lyxia>
okay so, given a path l, you can apply that generate_possible_paths, getting a list ps of paths extended from l
<lyxia>
then you can recursively call your pathfinding function on all paths of p
<Flerex>
Yes
<lyxia>
Does that make sense
<Flerex>
I think it does. I'm trying to translate what you said in code.
MercurialAlchemi has joined #ocaml
<Flerex>
okay lyxia, I got here: http://pastebin.com/dEQquWXX But I only get the long paths for the first element. I know that I have to use recursivity with aux but I don't know how.
<Flerex>
If I simply do generate_possible_paths n m h @ aux t I get this error:
<Flerex>
Error: This expression has type (int * int) list list
<Flerex>
but an expression was expected of type (int * int) list
<Flerex>
Type (int * int) list is not compatible with type int * int
<octachron>
Flerex, if I understand correctly, starting from a path p, the new possible paths depend only on the last state of the path?
jnavila has quit [Ping timeout: 256 seconds]
<Flerex>
Yes, which is the head.
<octachron>
in this case, it is probably simpler to write a function state -> path list
<octachron>
with path = state list
<Flerex>
Isn't possible_squares_by_path what you mean?
<Flerex>
I'd need, tho, the list to check if the next position is not repeated.
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
<octachron>
Flerex, your possible_square list computes the list of possible states next to the current state, isn't it?
<Flerex>
Yes
<Flerex>
I can link you all the code if you want
<octachron>
then a way to solve your problem is to write a function that computes from a state the list of all paths possibles from this state
<octachron>
: if you have a state s, first compute the possible next state nexts, from each next state computes the list of possible paths starting from this point, append s to all these paths
<lyxia>
Flerex: generate_possible_paths does one step. Then apply aux recursively to each resulting path to take care of unrolling the remaining steps
jnavila has joined #ocaml
myst|fon has joined #ocaml
mfp has joined #ocaml
rand__ has joined #ocaml
<Flerex>
lyxia: That's what I'm trying to accomplish right now here: http://pastebin.com/dEQquWXX but I don't know how to call the recursivity. If I concatenate aux t to generate_possible_paths n m h I get an error that says that t is of type pair list list instead of pair list.
ziyourenxiang has joined #ocaml
<octachron>
Flerex, what are supposed to be the input and output of your aux function?
<Flerex>
It should receive an initial list with one node [(x,y)] and return all the possible paths of max size (i.e., whose head has no more "next nodes")
<Flerex>
I think it should receive a list of lists instead to make the recursivity viable
<lyxia>
"apply to each" is map
<octachron>
Flerex, note that in general, if you have for precondition a list with exactly one element, you probably do not want a list as an input but the element itself
<lyxia>
It's the "one element" constraint that's too strong here
<Flerex>
Thanks octachron. I just don't know what I'm doing. I'm really bad at this.
<Flerex>
I'm trying to use map now.
larhat has quit [Quit: Leaving.]
larhat has joined #ocaml
<octachron>
Flerex, also, if your objective is to compute all possible knight tours, there are easier way to do this
<Flerex>
Don't tell me that now octachron. You'll make my cry hahhaha
<octachron>
Flerex, you should exploit the fact that you know the lenght of knight tours
<octachron>
which mean that if you have a function that compute valid paths of lenght (l+1) from path of lenght l, you know that you need to apply this function (n*m) time to get all possible tours
andyc has quit [Ping timeout: 244 seconds]
michbad has quit [Ping timeout: 260 seconds]
andyc has joined #ocaml
<testml>
is it possible to conditionally include modules in oasis ?
maattdd has joined #ocaml
silver has joined #ocaml
maattdd has quit [Ping timeout: 258 seconds]
larhat has quit [Read error: Connection reset by peer]
sz0 has joined #ocaml
larhat has joined #ocaml
MetaHertz has quit [Remote host closed the connection]
cic has quit [Quit: WeeChat 1.4]
michbad has joined #ocaml
michbad_ has joined #ocaml
michbad__ has joined #ocaml
michbad has quit [Ping timeout: 268 seconds]
michbad_ has quit [Ping timeout: 265 seconds]
tane has joined #ocaml
Flerex has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
jnavila has quit [Ping timeout: 260 seconds]
jao has joined #ocaml
jao has quit [Changing host]
jao has joined #ocaml
jao has quit [Quit: ERC (IRC client for Emacs 26.0.50.1)]
rand__ has quit [Quit: leaving]
fraggle_ has quit [Remote host closed the connection]
zirman has joined #ocaml
zirman has joined #ocaml
zirman has quit [Changing host]
unbalanced has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
tane has quit [Quit: Leaving]
ryanartecona has joined #ocaml
fraggle_ has joined #ocaml
chindy has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
Flerex has joined #ocaml
zirman has quit [Remote host closed the connection]