mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	| @@ -1923,6 +1923,13 @@ Myghty: | ||||
|   tm_scope: none | ||||
|   ace_mode: text | ||||
|  | ||||
| NL: | ||||
|   type: data | ||||
|   extensions: | ||||
|   - .nl | ||||
|   tm_scope: none | ||||
|   ace_mode: text | ||||
|  | ||||
| NSIS: | ||||
|   type: programming | ||||
|   extensions: | ||||
|   | ||||
							
								
								
									
										84
									
								
								samples/NL/assign0.nl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								samples/NL/assign0.nl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| g3 0 1 0	# problem assign0 | ||||
|  9 6 1 0 6	# vars, constraints, objectives, ranges, eqns | ||||
|  0 0	# nonlinear constraints, objectives | ||||
|  0 0	# network constraints: nonlinear, linear | ||||
|  0 0 0	# nonlinear vars in constraints, objectives, both | ||||
|  0 0 0 1	# linear network variables; functions; arith, flags | ||||
|  9 0 0 0 0	# discrete variables: binary, integer, nonlinear (b,c,o) | ||||
|  18 9	# nonzeros in Jacobian, gradients | ||||
|  0 0	# max name lengths: constraints, variables | ||||
|  0 0 0 0 0	# common exprs: b,c,o,c1,o1 | ||||
| C0 | ||||
| n0 | ||||
| C1 | ||||
| n0 | ||||
| C2 | ||||
| n0 | ||||
| C3 | ||||
| n0 | ||||
| C4 | ||||
| n0 | ||||
| C5 | ||||
| n0 | ||||
| O0 0 | ||||
| n0 | ||||
| r | ||||
| 4 1 | ||||
| 4 1 | ||||
| 4 1 | ||||
| 4 1 | ||||
| 4 1 | ||||
| 4 1 | ||||
| b | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| 0 0 1 | ||||
| k8 | ||||
| 2 | ||||
| 4 | ||||
| 6 | ||||
| 8 | ||||
| 10 | ||||
| 12 | ||||
| 14 | ||||
| 16 | ||||
| J0 3 | ||||
| 0 1 | ||||
| 1 1 | ||||
| 2 1 | ||||
| J1 3 | ||||
| 3 1 | ||||
| 4 1 | ||||
| 5 1 | ||||
| J2 3 | ||||
| 6 1 | ||||
| 7 1 | ||||
| 8 1 | ||||
| J3 3 | ||||
| 0 1 | ||||
| 3 1 | ||||
| 6 1 | ||||
| J4 3 | ||||
| 1 1 | ||||
| 4 1 | ||||
| 7 1 | ||||
| J5 3 | ||||
| 2 1 | ||||
| 5 1 | ||||
| 8 1 | ||||
| G0 9 | ||||
| 0 1 | ||||
| 1 3 | ||||
| 2 3 | ||||
| 3 2 | ||||
| 4 3 | ||||
| 5 3 | ||||
| 6 3 | ||||
| 7 3 | ||||
| 8 2 | ||||
							
								
								
									
										2284
									
								
								samples/NL/balassign0.nl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2284
									
								
								samples/NL/balassign0.nl
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										49
									
								
								samples/NewLisp/queens.nl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								samples/NewLisp/queens.nl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| #!/usr/bin/env newlisp | ||||
|  | ||||
| (constant 'NUM 8) | ||||
|  | ||||
| (define (intersects? q1 q2) | ||||
| 	(or  | ||||
| 		(= (q1 0) (q2 0))  | ||||
| 		(= (q1 1) (q2 1)) | ||||
| 		(= (abs (- (q1 0) (q2 0))) (abs (- (q1 1) (q2 1)))))) | ||||
|  | ||||
| (define (variant? alist) | ||||
| 	(set 'logic nil) | ||||
| 	(cond | ||||
| 		((= (length alist) 1) true) | ||||
| 		((> (length alist) 1) | ||||
| 			(while (> (length alist) 1) | ||||
| 				(set 'q (pop alist -1)) | ||||
| 				(dolist (el alist) | ||||
| 					(push  | ||||
| 						(intersects?  | ||||
| 							(list q (inc (length alist))) | ||||
| 							(list el (+ 1 $idx))) | ||||
| 					logic -1))) | ||||
| 			(not (apply or logic))))) | ||||
|  | ||||
| (define (fork-by-line alist) | ||||
| 	(let (res '()) | ||||
| 		(dolist (i (sequence 1 NUM)) | ||||
| 			(set 'tmp alist) | ||||
| 			(push i tmp -1) | ||||
| 			(setf res (push tmp res -1))) | ||||
| 		res)) | ||||
|  | ||||
| (define (find-variants num) | ||||
| 	(let (res '()) | ||||
| 		(cond  | ||||
| 			((< num 1)  | ||||
| 				(begin (println "num < 1") (exit))) | ||||
| 			((= num 1)  | ||||
| 				(dolist (i (sequence 1 NUM)) (push (list i) res -1))) | ||||
| 			((> num 1)  | ||||
| 				(dolist (v (find-variants (dec num)))  | ||||
| 					(set 'passed (filter variant? (fork-by-line v))) | ||||
| 					(if (not (empty? passed)) (extend res passed))))) | ||||
| 		res)) | ||||
| 		 | ||||
| (set 'solutions (find-variants NUM)) | ||||
| (println (length solutions)) | ||||
| ;;(exit) | ||||
		Reference in New Issue
	
	Block a user